Time for some code clean up. ;) I modified to code to work as follows:
Move the main rect around with the mouse.
Adjust number of collision checks with left/right mouse button.
Displays frames per second, num of collision checks and collision status.
Now you should be able to understand the results better. A bit of advice, stop worrying if your game runs at refresh rate, there's too many pc variables. The better thing to do is code your game using delta timing or some other way to time your logic independant of refresh rate. It takes time sure, but it will save you a bunch of head ache in the future. ;)
Note: This was first time playing with the built in collision checking, wow..the frame rate varies widly depending if you're colliding or not. Very strange, but now I'm tempted to write a quick lunar lander game! :) lol..
Move the main rect around with the mouse.
Adjust number of collision checks with left/right mouse button.
Displays frames per second, num of collision checks and collision status.
Now you should be able to understand the results better. A bit of advice, stop worrying if your game runs at refresh rate, there's too many pc variables. The better thing to do is code your game using delta timing or some other way to time your logic independant of refresh rate. It takes time sure, but it will save you a bunch of head ache in the future. ;)
Note: This was first time playing with the built in collision checking, wow..the frame rate varies widly depending if you're colliding or not. Very strange, but now I'm tempted to write a quick lunar lander game! :) lol..
' SuperStrict ' Global x:Int Global y:Int Global ncol:Int = 10 Global frames:Int Global fps:Int Global startms:Int=MilliSecs()+1000 Global test:Int ' Graphics 1024,768,16 Global image:TImage=CreateImage(32,32) Global image2:TImage=CreateImage(32,32) Global back:TImage=LoadImage("background.png") ' <<<< change path as needed DrawRect 0,0,32,32 GrabImage(image,0,0,0) GrabImage(image2,0,0,0) ' ResetCollisions(0) ' HideMouse ResetCollisions(1) CollideImage(back,0,0,0,0,1) Repeat ' If MouseHit(1) ncol=ncol-1 If ncol<1 ncol=1 EndIf EndIf ' If MouseHit(2) ncol=ncol+1 EndIf ' x=MouseX() y=MouseY() ' SetBlend SOLIDBLEND DrawImage back,0,0 DrawImage image,x,y,0 DrawText "FPS: "+fps,0,0 DrawText "Num of collide checks: "+ncol,0,30 DrawText "Collide: "+test,0,60 ' test=0 For Local t:Int=1 To ncol If CollideImage(image,x,y,0,1,0) Then test=1 Next ' frames=frames+1 If MilliSecs()>=startms startms = MilliSecs()+1000 fps=frames frames=0 EndIf ' Flip 0 ' Until KeyDown(KEY_ESCAPE) ' ShowMouse ' ' '