Fixed Rate Logic vs Flip(-1) Usage?
BlitzMax Forums/BlitzMax Beginners Area/Fixed Rate Logic vs Flip(-1) Usage?
| ||
Hi! im trying to understand what´s the advantage of implementing a Fixed Rate logic on a game vs the usage of Flip -1 ... as far as i get this.... if i set my Graphics Object to 60 hertz and flip to -1 then each second ill have 60 average loops, right? Isnt that like an implicit Fixed Rate Logic or something? Thanks! |
| ||
Sort of. First of all, try using Flip 1 instead of Flip -1, because it will try to sync with the vblank and avoid slicing, which does happen otherwise on some machines, macs especially. Fixed rate logic means you run your logic at a specific fixed Hz rate - a given number of times per second, like 120 or something, and then *usually* this logic updates *separately* from the graphics rendering, which would be at 60hz. In some cases the logic can run slower than the graphics, with tweening. So technically you could have logic and graphics both at 60hz and call it fixed rate logic, but the idea really is to detach your AI/scripting/animation/calculations from your graphics rendering, so that the logic always runs at a fixed rate even if there isn't enough time to draw the graphics at 60hz every second. The graphics would then slow down but objects would still appear to move at the same `speed` over time and cover the same distance over time. Just using Flip -1 or Flip 1 isn't going to do that for you, it's going to connect the logic to the graphics and BOTH will slow down if there is not enough cpu/gpu time. Look up fixed rate logic somewhere like google or wikipedia or even on these forums there's been extensive discussions about it. Using Flip is only going to give you smooth operation if there is a) enough time to draw all the graphics and b) enough time to do all calculations every frame, ie the computer is fast enough to never drop below 60hz. But when it is not fast enough, then you have a problem, which fixed rate attempts to solve. |
| ||
Hey, thanks for the reply! I saw those topics and im trying to implement fixed rate logic to my program. In fact i´ve red throught your entire explanation of Delta timing and fixed rate logic before doing that... thanks for the clarification! by the way.. the thing im doing is something like this: SuperStrict Graphics 1024, 768, 16 'Set Hertz Rate for logic at 16 millisecs (60 hertz) Local HertzRate:Int = 16 'set counter Local counter:Int = 0 'set render flag Local render:Int = 0 Repeat If counter = 0 Then counter = MilliSecs() If render = 1 Program.Draw() render = 0 Flip(1) ;Cls EndIf If counter + HertzRate <= MilliSecs() Program.Update() counter = MilliSecs() render = 1 End If Until KeyDown(KEY_ESCAPE) Or AppTerminate() I dont know if im doing it right, but this is what i understood... |