Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I never did physics in my life and this is really hard for me. I am currently trying to implement movement in the X and Y axis of a plane, in a video game I am making.

What I want to do is, given a starting angle and a velocity, and the value of gravity, calculate in different points of time the current angle and the displacement in X and Y.

So, lets say, my current velocity is 4 units / second and my current angle is 30 degrees and my gravity is 9.8 u/s, I want to pass an argument in seconds and calculate the final angle, velocity, and the amount of X and Y the body moved.

share|improve this question

migrated from Jan 9 '13 at 8:23

This question came from our site for active researchers, academics and students of physics.

Gravity's acceleration is 9.8 u/s^2, sorry couldnt resist ;) Using a physics engine like bullet is not an option? – Maik Semder Jan 9 '13 at 8:55
That would be useless, as I don't want to implement collisions and complicated movement. I am actually making a fan-made game of Super Mario 64 – Pacha Jan 9 '13 at 20:02
up vote 0 down vote accepted

If the acceleration is constant, e.g. the only force acting on the body is gravitational, we can use a trivial expression for the displacement at any time. It is a integrated twice with respect to t. In vector form: x(t) = x(0) + v(0) t + ½ a.

The starting velocity can be derived from θ using: v = v (cos θ, sin θ) or a variant, depending on how the angle is defined.

With the example values of:

  • x(0) = (0, 0)
  • v(0) = 4
  • θ = 30°
  • a = (0, -9.8)

the displacement can be calculated as: x(t) = (2√3, 2) t + (0,-4.9) t².

share|improve this answer
this worked, thanks – Pacha Jan 9 '13 at 20:03

Just do your math step by step (as long as you're not looking for complex simulation of this):

To move the plane based on its acceleration (plane.a; can be constant or 0) you should first calculate its velocity along the axes:

plane.vx += plane.a * cos(plane.angle) * delta_time / 2.0;
plane.vy += plane.a * sin(plane.angle) * delta_time / 2.0;

This should get you some basic movement. Based on your coordinate system (e.g. in which direction the y coordinate becomes bigger) you might have to negate one or more parameters.

Once this is done, just apply the gravity as well:

plane.vy += gravity * delta_time / 2.0;

Then you can just update your coordinates:

plane.x += plane.vx * delta_time;
plane.y += plane.vy * delta_time;

If you're using fixed time steps in your logic, you can just assume delta_time being 1, which makes the whole calculation even easier to be done. The velocities become simple deltas and your acceleration essentially becomes a constant velocity:

plane.x += plane.v * cos(plane.angle);
plane.y += plane.v * sin(plane.angle) + gravity;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.