Frame Rate Independant Code Done Simple. by Mage6th Jun 2007 15:39
|
---|
Summary Framerate independent code. An ultra simple method for making games run the same speed no matter what the frame rate is. Even if the framerate jumps around. Description Framerate independant code. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Dim Master_FrameTimer#(0) Dim Master_FrameLast(0) Global FrameX# Do FrameTimer() `PUT MAIN LOOP CODE HERE //// Sync Loop Function FrameTimer() Diff# = ABS(Timer() - FrameLast(0)) Ideal# = 1000.0 / 60.0 FrameX# = Diff# / Ideal# If Diff# > 1000 then FrameX# = 0 FrameLast(0) = Timer() EndFunction Function FrameTimer_Reset() FrameLast(0) = Timer() EndFunction |