[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] frame independant movement



On Fri, Aug 27, 2010 at 9:10 AM, Christopher Night <cosmologicon@xxxxxxxxx> wrote:
Sure. But of course, it's extremely easy to do constant-acceleration motion as well:

y += vy * dt + 0.5 * g * dt ** 2
vy += g * dt

Sure, that explicit integration technique works fine if you can write an explicit integration function - I've used that same technique even with fixed time-steps because it's more accurate. But now how about if you have acceleration and friction for a car driving on a surface - can you write a single dt based function for that? now how about something that is accelerating away with a spring on it? or maybe something falling while accelerating off axis with a spring attached? It very quickly gets beyond your ability to write such functions if you try and do really interesting stuff.

While consistent timesteps on the other hand, make it so the thing is always consistent and repeatable, even with simple update functions. Don't you want your game to behave the same regardless of frame rate? If you do, then fixed timestep simulation loops is a simple elegant widely used solution.