;Speed Test ;Compares Clipping to bound checking ;Wargamer Graphics 800,600 SetBuffer BackBuffer() Rect 0,0,100,100 ;test image, as the image gets larger ;Bound checking gets faster relative clipping hand=CreateImage(100,100) GrabImage hand,0,0 ;Test simulates a playfield of 2400 by 1800 pixels ;Objects (rectangles,text,images) can appear anywhere ;Test 1 Clipping SeedRnd 445434305899 t0=MilliSecs() Origin -800,-400 For i=1 To 10000 Color Rnd(255),Rnd(255),Rnd(255) Rect Rnd(2400),Rnd(1800),200,100 Color Rnd(255),Rnd(255),Rnd(255) Text Rnd(2400),Rnd(1800),"Dummy" DrawImage hand,Rnd(2400),Rnd(1800) Next ;Test 2 Bound Checking t1=MilliSecs()-t0 Cls Origin 0,0 SeedRnd 445434305899 mapx=800 mapy=400 t0=MilliSecs() For i=1 To 10000 x=Rnd(2400)-mapX y=Rnd(2400)-MapY If x>0 And x<800 If Y>0 And Y<600 Color Rnd(255),Rnd(255),Rnd(255) Rect x,y,200,100 EndIf EndIf x=Rnd(2400)-mapX y=Rnd(2400)-MapY If x>0 And x<800 If Y>0 And Y<600 Color Rnd(255),Rnd(255),Rnd(255) Text x,y,"Dummy" EndIf EndIf x=Rnd(2400)-mapX y=Rnd(2400)-MapY If x>0 And x<800 If Y>0 And Y<600 Then DrawImage hand,x,y EndIf Next t2=MilliSecs()-t0 Cls Color 255,255,0 Text 100,100,"Clipping "+Str$(t1) Text 100,120,"Checking "+Str$(t2) Flip WaitKey() End