Re: Difference between frames and milliseconds?

Most modern games do not in fact use frames with timers anymore, because in actuality your display can be set to 30, 60, or 120 FPS.  You want to convert to seconds with 1/framerate, then everything that takes tick takes a parameter called delta which is always 1/framerate in seconds.

Why delta?  Because in practice, if you go further, it can become important to limit the game to the framerate, but instead of passing the framerate in you pass the actual time since the last frame in.  These can be wildly different if i.e. the aforementioned antivirus hates you.  Does it usually matter?  No, but it can (think a rhythm game for instance).  And the standard naming for something that represents change mathematically is delta.  For example deltaXZ, deltaY, etc.  BUt since time is so common why deltaTime, when delta is more convenient.

Also by using seconds, you can change the framerate.  This is a free way to make your game take less resources.

And working in time lets you say "2 meters per second" and then you get how much movement since the last tick with velocity_in_seconds*delta, and if the framerate does ever change it won't explode.

Then you write a tiny clock class around this if you want a higher level piece that just increments delta in tick and calls whatever events you want called on whatever schedule.  Or find one, maybe that's what Pygame gives you.

Audiogames won't ever have to deal with it, but the sighted stuff can even have *multiple* framerates.  One for graphics, which has to happen at the rate of the display, and one for simulation, which can often be done as little as 10 times a second and can also be incredibly expensive.  XNA does this for example, not that anyone uses XNA anymore.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector

Reply via email to