When to Use Delta Time

of course for something like this one would use a fixedtick rate of i.e. 100Hz

FTFY ;D

I can see I was as clear as mud…let me strip down what I’m saying and retry.

Motion equations are continuous functions and “require” integration to be correct (to the model). Numerically integration is only correct if you are using the set of constraints that the given method was designed to handle. For example the “wrong” way above is actually correct if velocity is constant for each time slice and the “correct” way is only correct if acceleration is constant for each time slice. (Actually I’m over simplifying for a wider target audience here.) So neither are ever correct as we would use them. I don’t care…and neither should you. Correctness to a model is boring. All that really matters is that it “feel” right and behaves as expected to the player in game. What’s I’m really babbling about is another feature that I desire: being deterministic. Which is fancy speak for giving the exact same result each time it’s run, assuming all the initial data is the same. Now being correct to a model will give deterministic results…but it’s a PITA when possible and usually it impossible. So my suggestion is to not bother. Use the simpliest equations that give the feel you want, run at a fixed simulation rate and move on (or better yet, use an existing library).

Thanks guys.

I’m gonna go with fixed frame rate. I guess I really don’t have a reason to go for variable frame rate. Fixed rate sounds much easier to control.

Yeah, it has sleep and will only go slow as princec said.

instead of doing


int phase = 17
...
while(true)
{
  long now = getTime();
  tick();
  Thread.sleep(max(phase - (getTime() - now)), 0);
}

doing would fix the problem of missed frames, which result in slowdowns


int phase = 17
...
while(true)
{
  long now = getTime();
  int ticks = now/phase - last/phase;
  for(int i=0; i<ticks; ++i)
    tick();
  last = now;
}