Page 1 of 1

Time-Step Limiter

Posted: Tue Aug 25, 2009 12:12 pm
by Kjell
:idea:

Should have been build-in, but it's a piece of cake to do yourself. A minimum time-step limiter .. when the framerate drops below this limit, the game slows down.

Code: Select all

Limit = 1/15; // Minimum at 15FPS

if(App.DeltaTime < Limit)Delta = App.DeltaTime; else Delta = Limit;
Obviously you shouldn't use the Model.Velocity property anymore when taking this approach, but the same goes when writing your own Collision / Physics library.

K

Posted: Tue Aug 25, 2009 1:18 pm
by VilleK
I believe if you set a fixed frame rate to your game then deltatime will never go below that rate. But we should also have a built-in guard to prevent deltatime from being zero. Have you run into problems with too small deltatime?

Posted: Tue Aug 25, 2009 1:59 pm
by Kjell
Hej Ville,

The thing is .. when using a fixed framerate the desired rate is also the time-step limit, meaning that your game will always "slow down" when the desired rate isn't met. While with the solution I posted you can determine a range in which your game uses a variable time-step, while switching to the fixed delta when the framerate drops below a certain number.

+ This is a solution for dealing with delta times that are too high .. not too low ( there is no such thing :wink: ).

K

Posted: Tue Aug 25, 2009 2:21 pm
by VilleK
Ah, I didn't notice it was a max step limiter, I read it too quickly.

ZGE already have a built-in max limiter at 10 fps.

ZApplication.pas line 722:

MaxUpdateStep = 1.0 / 10;

Posted: Tue Aug 25, 2009 2:32 pm
by Kjell
:)

Was aware of that as well, but it's probably too complicated for most users that they have to recompile the source when they want a limit other then 10fps. Would be ideal if it was a property on App :wink:

K

Posted: Wed Aug 26, 2009 7:17 am
by kattle87
Agreed! We do need something like this I think ;)
Because for some games, it can be really useful to set a limit, to prevent missing collisions, and stuff.