© Graeme Stuart 2017

Graeme Stuart, Introducing JavaScript Game Development , https://doi.org/10.1007/978-1-4842-3252-1_6

6. Basic Animation

Graeme Stuart

(1)Market Harborough, Leicestershire, UK

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

Get Introducing JavaScript Game Development : Build a 2D Game from the Ground Up 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.