Advertisement

Controlling the Ship

  • Graeme Stuart
Chapter

Abstract

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 actual moving.

Copyright information

© Graeme Stuart 2017

Authors and Affiliations

  • Graeme Stuart
    • 1
  1. 1.Market HarboroughUK

Personalised recommendations