Otherwise, I may suggest that it’s almost never a good idea to tie your
code to a specific framerate
I disagree, in fact a fixed frame rate, have a couple of advantages, despite
of its disavantages:
- Easier to calculate movements, the code feels more readable, no *
deltaTime everywhere
- Easier to be deterministic, which is good if you want to create a replay
system and/or make an online game.
- Better for timing games (if you can keep the framerate well enough)
Very good points - which is why I tend to stick with this type of
solution. (The Fixed Rate Pig example, Kobo Deluxe and Kobo II so
far.)
However…
Of course, If you go with fixed framerate, it will be necessary to implement
a Frameskip system, which is not hard, but tricky.
Actual frame skipping is not very nice from an animation/smoothness
point of view - and it’s absolutely horrible if you can’t get a
display refresh rate very close to 60 Hz, or whatever you’ve designed
for. (Some displays only have a fixed refresh rate - and it’s not
always 60 Hz. In other cases, the OS or drivers won’t let you select
refresh rates at all. Basically cannot rely on that at all.)
The solution is to implement interpolation, also known as tweening in
this context. The downside of this is that it adds one “logic” frame
to the input-to-display latency, which isn’t desirable in fast action
games, obviously.
Another option is to use extrapolation. (I’m doing that by default in
Kobo II.) This can theoretically cause objects to overshoot slightly
at drastic velocity changes. However, if the game logic is running at
a “reasonable” rate (100 Hz in the case of Kobo II), this is only an
issue with extremely fast moving objects - so fast that they shouldn’t
really be rendered as plain sprites anyway. (Those objects would
instead “undershoot” with interpolation/tweening, so that’s not really
a solution either.)
I hope that makes some sense… :-DOn Thu, Feb 7, 2013 at 9:57 PM, Rodrigo wrote:
–
//David Olofson - Consultant, Developer, Artist, Open Source Advocate
.— Games, examples, libraries, scripting, sound, music, graphics —.
| http://consulting.olofson.net http://olofsonarcade.com |
’---------------------------------------------------------------------’