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

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