O'Reilly logo

Learn Game Programming with Ruby by Mark Sobkowicz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Start Over with Scenes

Breaking a game into scenes is a flexible way to incorporate all kinds of mechanics into the game. Scenes could be game levels, short animations, or rooms in a dungeon. They help break a complex game into manageable chunks, like separate mini games that you can build one at a time.

To organize your game into scenes, you’ll write a completely new SectorFive class, but in it you’ll reuse much of the code from the old one. You won’t change your sprite classes at all. In the new SectorFive class, you’ll create separate update and draw methods for each scene. Most of the code you wrote in the past few chapters goes into the methods for the game scene.

Because you’re starting over, you’ll make a new file for your new SectorFive ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required