; WaitTimer Example ; ----------------- Graphics 640,480,0,2 SetBuffer BackBuffer() ; WaitTimer halts the program until the next tick of a timer made with ; CreateTimer, locking the loop to the timer's rate. It returns how ; many ticks have passed since the last wait - normally 1, more if the ; loop fell behind - so you can catch up on missed ticks. timer=CreateTimer(60) ticks=1 While Not KeyDown(1) Cls ; Hold Space to fake a slow frame (60 ms of extra work) If KeyDown(57) Then Delay 60 ; Move one step per elapsed tick: when frames are dropped, ; ticks>1 makes up the lost ground and the speed stays constant x=(x+4*ticks) Mod 640 Rect x,220,40,40,True Text 0,0,"Hold Space: fake a slow frame Esc: exit" Text 0,20,"WaitTimer returned "+ticks+" tick(s) this frame" ; Flip False: don't also wait for the monitor - the timer sets the pace Flip False ; The documented command: wait for the 60 Hz timer's next tick ticks=WaitTimer(timer) Wend End