To make my game fps independent I move entities with
pos += speed * time
where time is the delta time since last frame.
That works perfectly well with speed but how do you do that with acceleration?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
You'll likely be using constant acceleration. So no need to worry! The derivative of constant acceleration with respect to time is 0. That means it doesn't change with respect to time, so it doesn't matter what your frame rate is. If you were using variable acceleration you'd set up your equation like:
acc += jerk * time //only needed if your acceleration isn't constant speed += acc * time //calculates the current velocity given the acceleration pos += speed * time //calculates the position given the current velocity
The jerk is the rate of change in your acceleration.
You may want to check out the equations of motion.
Since your math is coming back to you, you may remember that using the Euler form above is fairly inaccurate. So you may remember this little integration with respect to time process from physics:
Where: a=acceleration, v=velocity, v0=initial velocity, s=position, s0=initial position, t=time
If you derive your position using that equation instead, you'll get far more accurate results.