gfx driver sprite test

BlitzPlus Forums/BlitzPlus Programming/gfx driver sprite test

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The example

SetGfxDriver 1
Const w=320;screen width
Const h=240;screen hight
Graphics w,h,16,2
Dim x(50000)
Dim y(150000)
Dim statex(50000)
Dim statey(50000)
statey(0)=1
statex(0)=-1
b=500;number of sprites

;create dot sprite
sprite=CreateImage(1,1,1)
SetBuffer ImageBuffer(sprite)
Color 255,255,255
WritePixel 0,0,$ffffff
SetBuffer BackBuffer()


;set up sprites
For n=0 To b
statey(n)=1
statex(n)=-1
x(n)=Rnd(w)
y(n)=Rnd(h)
Next


;main loop condition
While Not KeyHit(1)

time1=MilliSecs();start timing

Cls 

For n=0 To b
DrawImage sprite,x(n),y(n) ; Draw the image!
x(n)=x(n)+1*statex(n)
y(n)=y(n)+1*statey(n)
If x(n)>w Then statex(n)=-1
If x(n)<0 Then statex(n)=1
If y(n)>h Then statey(n)=-1
If y(n)<0 Then statey(n)=1
Next

;average time
;time2=time2+MilliSecs()-time1
;time3=time3+1
;time4=time2/time3
;text 0,20,time4
Text 0,20,MilliSecs()-time1;find out how quick it was.

Flip 0;
Wend