© Graeme Stuart 2017

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

2. Understanding Paths

Graeme Stuart

(1)Market Harborough, Leicestershire, UK

Chapter 1 introduced some of the basic methods for drawing to the canvas. This chapter presents a follow-up exercise that looks more closely at the canvas coordinate system and explores how to construct paths. These concepts are critical to understanding the canvas and designing your own drawing code.

We’ll also start to add a bit more structure to our code. Complex code can be difficult to comprehend—adding structure is the main way to keep the complexity under control. Structuring code into functions allows the development of simpler code that uses ...

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.