Move the Ship

The player moves the ship by pressing three keys. Gosu treats keys exactly the same as mouse buttons and calls all of them buttons. You use the left arrow, the right arrow, and the up arrow to move the ship. The ship moves forward by firing its engines; the ship doesn’t have any way to fire the engines backward. If you stop firing the engines, the ship coasts gradually to a stop.

Of course, this isn’t actually realistic, but our primary goal is to make the game fun. Sometimes realistic is fun, and sometimes realistic is just frustrating. Our job as game designers is to strike the right balance. In this game, we want moving the spaceship around to be fun. We use some ideas from physics to make the ship feel like a real object ...

Get Learn Game Programming with Ruby 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.