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

Re: [pygame] Framerate Normalizer



I usually either use time directly in my calculations (rather than fps), because I find it more natural. Does the velocity depend linearly on thrust, or is thrust an acceleration? If the units on thrust are something like meters per tick squared, then I think you will need to compensate twice for the change in frame rate.

meters/newtick^2 = meters/oldtick^2 * (oldtick/newtick)^2

--Mike

Ian Mallett wrote:
Hello,
I have a game, written in pygame, but it now needs to support more framerates. The movements of objects need to be at the same speed, regardless of the framerate.
Here is an old line:

self.thrust = 0.0075

Here is the new line. The game was developed on my computer at 198 fps (IdealFPS), but now needs to be scaled to a lower one for use on alternate computers (TargetFPS). The theory here is to multiply this rate by IdealFPS to give the distance moved in one second, then divide this difference by the number of frames in second there will really be. (TargetFPS).

self.thrust = (0.0075*IdealFPS)/TargetFPS

Unfortunately, this doesn't work--the movement doesn't scale properly. Any ideas why?
Thanks,
Ian