Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8: Making Bigger Games > Understanding the game structure

Understanding the game structure

The structure of the code in Monster Mayhem game is radically different from any previous games you've made in the book so far. Each level of the game is contained entirely inside a single Sprite. When a level is complete, the main application class removes the current level Sprite from the stage and adds a new one. That means that none of the game objects, like the character or the monsters, are added to the main stage. They're all first added to a containing Sprite. And it's that containing Sprite that's added to the stage by the application class.

To get a clearer idea of how this works, let's compare the structure of Monster Mayhem with Time Bomb Panic. In Time Bomb Panic, all the game objects are created as separate classes. Those classes are then added directly to the stage in the main application class. Figure 8-2 illustrates this structure at work.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint