Original Post
I've been using a fixed frame rate for my game but I now want to
change this so that all the physics are calculated from the time elapsed between each update. I'm just a little confused as to what values to change. At the moment I have a spaceship that is updatedlike this...
#define MASS 1
#define MAXVELOCITY 10
#define MAXTHRUST 5
Spaceship::Update()
{
accel += current_thrust / MASS;
velocity += accel;
velocity.truncate(MAXVELOCITY);
pos += velocity;
}
I have now changed this to:
Spaceship::Update(float time_elapsed)
{
accel += current_thrust / MASS;
velocity += accel * time_elapsed;
velocity.truncate(MAXVELOCITY);
pos += velocity * time_elapsed;
}
Which I think is correct, but I'm now unsure how to adjust the
MAXVELOCITY, MAXTHRUST values so that my ship behaves the same as it did with a constant frame rate.
Can anyone help?
[edited by - jeffB on April 28, 2003 6:23:29 AM]