© 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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.