Given the time interval since the last update and a force to be applied, we
can create a method that updates the ship’s position and velocity. Here’s
void SpaceShip::Update(float TimeElapsedSinceLastUpdate, float ForceOnShip)
float acceleration = ForceOnShip / m_fMass;
First of all, calculate the acceleration due to the force using equation
m_Velocity += acceleration * TimeElapsedSinceLastUpdate;
Next, update the velocity from the acceleration using equation (1.80).
m_vPosition += m_Velocity * TimeElapsedSinceLastUpdate;
Finally, the position can be updated with the updated velocity using equa-
This chapter covers a lot of ground. If much of this stuff is new to you,
you’ll be feeling slightly confused and perhaps a little intimidated. Don’t
worry though. Soldier on and, as you read through the book, you’ll see how
each principle is applied to a practical problem. When you see the theory
used in real-world contexts, you’ll find it a lot easier to understand.
40 | Chapter 1