Forces

When you're getting ready to start the physics simulation portion of the code, the first step is to brainstorm all the forces that are acting on the object you want to move. The sum (or total) of all those forces determines how the object moves. Some of the forces are obvious: an enemy punches or kicks the player, the player pushes a large object out of the way, a ball is thrown, or a missile is launched. However, some less-obvious forces often get overlooked: gravity, friction, wind resistance (if it's significant), or the normal force. Let's stop and take a closer look at how each of these forces works, starting with gravity.

Earlier, we discussed acceleration due to gravity, which is represented in most formulas as the constant g.

Get Beginning Math and Physics for Game Programmers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.