I was messing around with trying to come up with another way to do fixed rate logic with render tweening in Blitz3D and came up with this. Please tell me if it sucks or if it's a hit. It seems to run freaking awesome and smooth as hell here. I can't find any flaws in it. It's based on Gaffer's fixed rate logic stuff and the tweening example in the archives.
Const dt# = 1.0 / 50.0 ;(50 FPS Logic)
Local newTime% = MilliSecs()
Local oldTime = newTime - 1
Local accumulator#, deltaTime#, alpha#, t#
While Not KeyHit(1)
Cls
newTime = MilliSecs()
deltaTime = (newTime - oldTime) * 0.001
oldTime = newTime
accumulator = accumulator + deltaTime
While accumulator >= dt
CaptureWorld
Update_GameLogic(dt)
accumulator = accumulator - dt
t = t + dt
Wend
alpha = accumulator / dt
RenderWorld alpha
Flip False
Wend
EndGraphics
End
|