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

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.