Game Timing - How?

Monkey Forums/Monkey Programming/Game Timing - How?

Chroma(Posted 2013) [#1]
In BMax, timing was simple due to we got to do it ourselves. But in Monkey there's already a game timing function (SetUpdateRate). There's no reason to write another timing piece of code and put it inside the OnUpdate() because then you'll have a game timer inside a game timer.

So here's my question... How can I access Mark's game timer data? I know there has to be a delta time variable and accumulator. That's really all the info I need to calculate the tween value.


Dima(Posted 2013) [#2]
I'm not sure it would help - because as far as I know, Mojos timing doesn't use a true fixed step interval - rendering runs at the same rate as update but there is no guarantee that it always does, I think if rendering can't keep up it will skip a frame and do extra updates.

If you still need the timing data but can't find it in Mojos code, you could at least try and make your own accumulator using Millisecs(), don't know how accurate this would be but we can figure out the frame delta using update rate like 1/60.

One could implement fixed step interval logic like Gaffers in the OnRender() method basically ignoring OnUpdate(), just set UpdateRate high enough so rendering isn't limited, then you could run your updates low frequency and tween positions etc at render time. That's a lot of extra work though, I find it easy to just use Mojos timing.


Chroma(Posted 2013) [#3]
Yep I have an FRL + Tween (Gaffers to be exact) that I've ported from my BlitzMax code. It gives the smoothest rendering I've ever seen but...I just don't want to stick a timer inside a timer...


Chroma(Posted 2013) [#4]
Well the Gaffer method is causing major problems when the FPS dips so I'm thinking it's not worth it. I'm going to rip out all my timing code and just use the delta correction code from the Sample code. I don't want to spend weeks trying to reinvent the wheel when it's basically already there.