Game Timing

Community Forums/Monkey2 Talk/Game Timing

Chroma(Posted 2015) [#1]
Hi,
I'm very excited for the arrival of Monkey2 and I have a question. Will game timing be platform independent, meaning for each platform the best timing method will be used to give smooth logic timing and drawing rates? This is a huge concern to me.

Thanks,

Chroma


Nobuyuki(Posted 2015) [#2]
Timers, as used in MonkeyX, rely on the underlying target's implementation. Since mx2 is using mojo2 for its target, and the primary target is C++ based, it's reasonable to assume that the current timer being employed is the one GLFW uses. Here is what the GLFW docs say about its timer:

The resolution of the timer is system dependent, but is usually on the order of a few micro- or nanoseconds. It uses the highest-resolution monotonic time source on each supported platform.


To access timers independently will likely require a separate module, but for game timing, this is what you can reasonably expect.


marksibly(Posted 2015) [#3]
IMO, the best timing mechanism is always 'vsync' which will of course be supported!

As for timers, monkey2 will support 'New Timer' which will use an SDL_Timer under the hood. I'm not totally sure how these are implemented, but the SDL guys know what they're doing so I expect it to work fine. If not, the source is there we can always go in and fix things.

SDL also offers high performance counters, so it will be easy to make these public too.


Nobuyuki(Posted 2015) [#4]
Aha, I'd totally forgotten that the runtime was going to be using sdl2. Apologies for the misinformation!