How ever, using a fixed rate logic, means you need to figure out how to tween between the last logic frame and the new logic frame to make the display.
It's not necessary at all. Just draw everything at whatever position they are currently at. If you're using a high rate (e.g. 200 updates per second or more), using tweening for the display is going to make little visual difference to the player. Tweening and/or delta only come into it when the updates per second are less than the refresh rate of the display.
However, some people like to combine the two methods to give the smoothest possible experience, but I think it's a lot of effort for little gain. Only the programmer is going to notice any difference becaise they are looking for it. The casual gamer will be too involved in the game to notice any difference - as long as the game looks and feels smooth.
Thanks a lot. Another question, what is the best or standard way to separate drawing from logic?, right now i have each object draw when it updates its logic, how should i separate them?, thanks.
Each of your objects needs to have separate Update and Draw methods. In terms of the coding, the following is a little program I wrote when I first started experimenting with this. It's probably the simplest way of doing things, but will serve as a good starting point.
Strict ' ----- Preferences ----- Const scrWidth:Int=640,scrHeight:Int=480 ' screen resolution to use Const scrDepth:Int=32 ' bitdepth to use Const monitorFPS:Int=85 ' preferred monitor frequency Const logicFPS:Int=200 ' number of times to update logic per second Const logicMaxUpdates:Int=logicFPS/20 ' maximum number of logic updates in any one loop ' ----- Constants ----- Const logicSpeed:Int=1000/logicFPS ' time difference between logic updates ' ----- Control Globals ----- Global systemTime:Int ' holds system time before entering logic update loop Global gameTime:Int ' current time in relation to system time Global logicCount:Int ' used to check if game is running slow ' ----- Set Up Graphics ----- Graphics scrWidth,scrHeight,scrDepth,monitorFPS ' set up graphics HideMouse ' ----- Main Loop ----- Global mx:Int,my:Int ' just used for testing Global rectX:Int=0,rectY:Int=0,rectW:Int=16,rectH:Int=scrHeight ' constantly moving object systemTime=MilliSecs() ' grab system time gameTime=systemTime ' put game at same point While Not KeyHit(key_escape) logicCount=0 systemTime=MilliSecs() While gameTime<=systemTime UpdateLogic() gameTime:+logicSpeed ' update game time logicCount:+1 ' increase update count If logicCount>logicMaxUpdates Then Exit ' quit update loop if max updates reached Wend Render ' check for timer wrap (they'll be a stutter, but heck, it happens every 1200 hours!!!) If MilliSecs()<systemTime Then gameTime=MilliSecs() Wend ' ----- Support Functions ----- Function UpdateLogic() ' grab mouse co-ordinates mx=MouseX() my=MouseY() ' update rectangle rectX:+1 If rectX=(scrWidth-rectW) Then rectX=0 EndFunction Function Render() Cls SetColor 255,255,0 DrawRect rectX,rectY,rectW,rectH SetColor 255,255,255 DrawLine mx-16,my,mx+16,my DrawLine mx,my-16,mx,my+16 Flip EndFunction
Hope it helps.