Game Development Reference
In-Depth Information
Often these states are completely mutually exclusive, but sometimes we might want
several states active, or at least visible, at the same time. For example, quite often
the pause mode will appear on top of the game screen. Only the pause mode will be
accepting input, but both it and the game screen need to be drawn.
One approach (and this is purely my own personal preference; your own may vary
wildly) is to create a separate class which handles a single part of the game. For want
of a better word, I represent these using a base class called Mode .
The Mode class is similar to the GameObject class in that it provides two virtual
methods called Update and Render . A mode can be made active, which means its
Update method will be executed in each frame, and it can be visible, which means
its Render method will be called. These two states are completely independent of
each other.
When a Mode instance is created, it is automatically added to a list maintained by
a singleton class called ModeManager . The ModeManager class uses the list of Mode
instances to update all active modes and render all visible modes on each iteration
of the main game loop.
Currently the project only consists of a single mode called ModeGame , which is
responsible for loading and freeing the required resources and also initializing,
updating, and rendering all the GameObject s that make up the game world.
Summary
In this chapter we've learnt about Marmalade's powerful resource management
system. We know how to use it at a simple level to just load and release resources
such as bitmapped images or our own custom classes; we also have a good idea
of how the resource management system is put together, and how we can extend
it with our own functionality.
We've also covered the options available for rendering on-screen images, and
seen how to use one of these, IwGx, to render polygons on the screen.
In the next chapter we'll be learning how we can start using the various input
options available on modern mobile devices, since the whole point of games is
that they are interactive.
 
Search WWH ::




Custom Search