Below is some frame limiting code from an article on BlitzCoder. Can someone explain to me why the UpdateGame() function is called only on the last iteration of the loop?
This means that the objects in the game will only be moved by one 'step', rather than 'ticks' steps. When you run through the loop calling UpdateWorld then no objects will be moving (although they will animate) because UpdateGame() is not being called every iteration.
I have also seen others using the same frame-limiting code, but they do not use CaptureWorld. What's the idea there?
This means that the objects in the game will only be moved by one 'step', rather than 'ticks' steps. When you run through the loop calling UpdateWorld then no objects will be moving (although they will animate) because UpdateGame() is not being called every iteration.
I have also seen others using the same frame-limiting code, but they do not use CaptureWorld. What's the idea there?
Const FPS=30 Global period=1000/FPS Global time=MilliSecs()-period While Not KeyHit(1) Repeat elapsed=MilliSecs()-time Until elapsed ticks=elapsed/period tween#=Float(elapsed Mod period)/Float(period) For k=1 To ticks time=time+period If k=ticks Then CaptureWorld UpdateGame() ;This is where all your game stuff should be updated EndIf UpdateWorld Next RenderWorld tween# Draw2DThings() ; Place 2D rendering stuff here between RenderWorld and Flip Flip Wend End