O'Reilly logo

The Essential Guide to Physics for Flash Games, Animation, and Simulations by Adrian Dobre, Dev Ramtal

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

Bouncing off horizontal or vertical walls

In the first application of collision physics, we will look at how to make a ball bounce off a straight wall that is either horizontal or vertical in a 2D simulation space such as a floor, ceiling, or room wall. For illustration, we use a vertical wall, but similar principles will apply to horizontal walls as well.

We'll look at elastic and inelastic bouncing in turn (bouncing in which the kinetic energy of the ball is or is not conserved).

Elastic bouncing

If the ball bounces elastically off a wall, its kinetic energy just after bouncing must equal its kinetic energy just before bouncing. Because k.e. = ½ mv2, this implies that its velocity magnitude is unchanged by the collision.

Consider first a special ...

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