Game Development Reference
In-Depth Information
The ModeTitle and ModeGameOver classes
These classes implement the title screen and game over modes of the game. These
have been added to make the project feel a little more like a game, although they are
very basic to look at.
More importantly, these classes show how we can switch between game modes by
making them active and visible. Take particular note of the ModeGameOver class,
which stops the normal game mode from updating, but still allows it to render so we
can see the game world along with the game over message.
The Camera class
The Camera class has been added to the project to allow us to specify a viewing
point in the world. When rendering, we now use the camera position as the origin's
location on the screen. So when we move the camera, the entire screen display will
move relative to it. This makes it possible to do a horizontal scrolling effect without
having to update the x coordinate of everything in the game world.
Another reason for making this change is to make our life easier when we upgrade
the game to use 3D models in the next chapter, since this is closer to the way 3D
graphics are rendered.
The Input Manager classes
Three new singleton classes have also been added to the project to make access
to key, touch screen, and accelerometer inputs a little tidier. They are called
KeyManager , TouchManager , and AccelerometerManager respectively.
These classes wrap the functionality provided by Marmalade into a simpler interface,
which makes our game code easier to read. It also means that we can make changes
to the inputs at a later date without having to change the game code. For example,
the KeyManager class provides methods to indicate if the left or right arrow keys
have been held. If we want to remap those keys or provide alternate possible keys,
we can do so in the KeyManager code and our game code will work just fine.
The SkierController class
In order to add a layer of abstraction between the Skier class and the various
input managers, the SkierController class has been added. This class provides a
"steering" value, which is an integer number ranging from— IW_GEOM_ONE to + IW_
GEOM_ONE that indicates how much the user is attempting to steer left (a negative
value) or right (a positive value). The Skier class can just use this value to rotate the
skier without needing to consider how this value is derived.
 
Search WWH ::




Custom Search