Skip to main content

Controlling the Ship

  • Chapter
  • First Online:
Introducing JavaScript Game Development
  • 1795 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 34.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 44.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Graeme Stuart

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Stuart, G. (2017). Controlling the Ship. In: Introducing JavaScript Game Development . Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3252-1_11

Download citation

Publish with us

Policies and ethics