O'Reilly logo

Core HTML5 Canvas: Graphics, Animation, and Game Development by David Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required