Chapter 7. Physics

Physics, or some approximation thereof, often plays a role in sprite-based animations, especially games. This chapter discusses fundamental physics used in a wide variety of animations:

• Gravity

• Nonlinear motion

• Nonlinear animation

From Sonic the Hedgehog to Cut the Rope, gravity is prevalent in video games, so we start with three of the most common applications of gravity: falling, projectile trajectories, and gravity applied to harmonic motion.

Harmonic motion provides the mathematical dropback for things such as springs and swinging pendulums. After an introduction to harmonic motion, we explore warping time to implement effects such as ease in, ease out, oscillations, and bouncing.

Let’s begin by looking at the weakest ...

Get Core HTML5 Canvas: Graphics, Animation, and 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.