News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Circle Tech Demo

Started by kevin, November 07, 2004, 11:46:01 AM

Previous topic - Next topic

kevin

Here's a bit of circle tech demo..  Showing PB's rather speedy circle command..  

This one runs about 60fps on my duron800, GF2 system.


PlayBASIC Code: [Select]
OpenScreen 1024,768,32,2

max=100

Dim ovalsdir(max,2)
Dim ovalpos(max,2)
Dim colors(max,3)
Dim speed(max)

For i=1 To max
Repeat
ovalsdir(i,1)=Rnd(2)-1
Until ovalsdir(i,1)<>0

Repeat
ovalsdir(i,2)=1-Rnd(2)
Until ovalsdir(i,2)<>0

ovalpos(i,1)=Rnd(1024)
ovalpos(i,2)=Rnd(768)
speed(i)=1+Rnd(4)
colors(i,1)=Rnd(255)
colors(i,2)=Rnd(255)
colors(i,3)=Rnd(255)
Next


Do

Cls 0
Randomize 1

LockBuffer

For i=1 To 50
Circle Rnd(1000),Rnd(700),80+Rnd(200),0
Next

For i=1 To max
CircleC ovalpos(i,1),ovalpos(i,2),60,0,RGB(colors(i,1),colors(i,2),colors(i,3))
ovalpos(i,1)=ovalpos(i,1)+ovalsdir(i,1)
ovalpos(i,2)=ovalpos(i,2)+ovalsdir(i,2)
If ovalpos(i,1)>965 Then ovalsdir(i,1)=-speed(i)
If ovalpos(i,1)<1 Then ovalsdir(i,1)=speed(i)
If ovalpos(i,2)>720 Then ovalsdir(i,2)=-speed(i)
If ovalpos(i,2)<1 Then ovalsdir(i,2)=speed(i)
Next

UnLockBuffer

Sync

Loop






kevin

Hmm, seem to handle 400 at around 30fps too.. neat , it's faster than i thought..   :)

medwayman

#2
Wow, that's very fast for all those circles. I get 68fps on a Duron 650, Radeon 7200.
PlayBASIC continues to impress :)

Here are some active ellipses rotating about the screens centre. 600 gives me 28fps  :)

PlayBASIC Code: [Select]
OpenScreen 1024,768,32,2

max=600

scr_w=GetScreenWidth()/2
scr_h=GetScreenHeight()/2

Dim pos_x_y#(max)
Dim raid_x_y(max,2)
Dim speed(max)
Dim col(max,3)
Dim direction(max)
Dim max_raid(max)
Dim count#(max)

For c=1 To max
pos_x_y#(c)=RndRange(50,550)

If Rnd(1)=0
raid_x_y(c,1)=RndRange(60,80)
raid_x_y(c,2)=RndRange(5,30)
Else
raid_x_y(c,1)=RndRange(5,30)
raid_x_y(c,2)=RndRange(60,80)
EndIf

If raid_x_y(c,1) > raid_x_y(c,2)
max_raid(c)=raid_x_y(c,1)
direction(c)=1
Else
max_raid(c)=raid_x_y(c,2)
direction(c)=2
EndIf

count#(c)=Rnd(360)
speed(c)=Rnd(4)+1

col(c,1)=Rnd(255)
col(c,2)=Rnd(255)
col(c,3)=Rnd(255)
Next c

Do
Cls 0
Text 10,10,Str$(FPS())

LockBuffer

For c=1 To max

If direction(c)=1
raid_x_y(c,1)=raid_x_y(c,1)-speed(c)
raid_x_y(c,2)=raid_x_y(c,2)+speed(c)
If raid_x_y(c,2)>max_raid(c) Then direction(c)=2
Else
raid_x_y(c,1)=raid_x_y(c,1)+speed(c)
raid_x_y(c,2)=raid_x_y(c,2)-speed(c)
If raid_x_y(c,1)>max_raid(c) Then direction(c)=1
EndIf

EllipseC scr_w+Sin(count#(c))*pos_x_y#(c),scr_h+Cos(count#(c))*pos_x_y#(c),raid_x_y(c,1),raid_x_y(c,2),0,RGB(col(c,1),col(c,2),col(c,3))
count#(c)=count#(c)+0.5*speed(c)
Next c

UnLockBuffer

Sync

Loop




empty

That's a neat demo. :)
Get solid 50 fps on Athlon 1800 and Radeon 9200.

medwayman

Sorry Kevin I should have put my effort in a new post.

Your code inspired me to do it so I just came here to post. I wasn't thinking
:wacko:

kevin

#5
Sorry?, hey I don't care, your effect is nice than my test..:)  PLus it's just really nice to see people messing with PB and posting code snippets..

medwayman