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