You are previewing Core HTML5 Canvas: Graphics, Animation, and Game Development.

Core HTML5 Canvas: Graphics, Animation, and Game Development

Cover of Core HTML5 Canvas: Graphics, Animation, and Game Development by David Geary Published by Prentice Hall
O'Reilly logo

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 ...

The best content for your career. Discover unlimited learning on demand for around $1/day.