A simple example

To see how all this works in practice, we will now look at a simple example. We'll set ourselves the task of simulating the motion of a ball thrown to the ground, using just a few lines of code.

To start with, let's try and picture the scenario that we are trying to model, the way it behaves in reality. Suppose you throw a volleyball in the air. How does it move? You've probably noticed that such a ball does not move in a straight line, but traces out a curved path. Moreover, the ball appears to move slowly at the top of the curve and quickly at the bottom, near the ground. When it hits the ground it usually bounces, but always reaches a lesser height than that from which it fell. Before we try to reproduce this motion, let us ...

Get The Essential Guide to Physics for Flash Games, Animation, and Simulations 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.