In previous chapters we’ve looked at the nuts and bolts of drawing to the canvas. Now that we have a bit of experience, we can turn our attention to animating a scene. Animation is quite easy—simply draw a changing scene multiple times per second. In this chapter we’ll learn to do this in a very simplistic way in order to understand the basics.
When drawing ships and asteroids, we need data about their location, size, shape, and so on. This data will be used to translate and rotate the context so everything appears in the right place. To animate a scene, ...