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

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