Reviewing 2-D Physics
You played with physics in Chapter 14, “Building Games with SVG and Physics,” when you used the JavaScript port of Box2D for physics and collision detection, but the Physics library handled the details of what you were doing without really diving into exactly what was going on. This is okay when you want a full-blown physics simulation without worrying about the nitty-gritty details, but often you just need some basic 2-D motion, so a full physics library would be overkill. For Lander, you want pixel-perfect collision detection, which would put a lot of strain on a traditional physics engine where theoretically each pixel must be modeled as a simulation object.
Understanding Force, Mass, and Acceleration
For those of you who took high school physics, the following equations should look familiar:
Equation 1: f = m × a or a = f / m
Equation 2: v = v0 + a × dt
Equation 3: p = p0 + v × dt
These are the basic 2-D dynamics equations that define the acceleration on a body as a function of its mass and the forces acting on it, and the ...
Get Professional HTML5 Mobile Game Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.