© Graeme Stuart 2017

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

8. Practicing Objects

Graeme Stuart

(1)Market Harborough, Leicestershire, UK

The benefits of the object-oriented approach should be clear by now. We can design our objects (Asteroid, Ship, and so on) with a simple and intuitive API. Our objects track their own state and update themselves when we ask them to (in their update functions). They can also easily be drawn to the canvas in the correct position with a simple function call (their draw functions). The game loop itself can update all our objects in turn and then draw them all. We should be able to read the high-level code without too much trouble. All the nitty-gritty details ...

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.