© Graeme Stuart 2017

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

11. Controlling the Ship

Graeme Stuart

(1)Market Harborough, Leicestershire, UK

In this chapter we’ll finally implement user control of the ship. This is where all the hard work in setting up our objects will begin to pay off. At the end of this chapter you’ll be able to fly the ship gracefully around the canvas and even shoot projectiles from the nose of the ship. As with the Pac-Man example, we’ll need to add some properties to our ship class so we can use keyboard events to control the ship. The ship remains a mass floating in space, so we only want to use the Mass.prototype.push and Mass.prototype.twist methods to do the ...

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.