Game Development Reference
In-Depth Information
Chapter 17
Game States
17.1 Introduction
In the previous chapter, we have programmed the main gameplay elements of the
Jewel Jam game. However, the game as it stands is still far from being complete. For
example, nothing happens when the jewel cart disappears from the screen. Also,
when you start the program, the game immediately begins without any warning.
What is still needed is a way to incorporate menus and overlays in the game so
that the player can change settings, get help, or start playing the game. When the
player is, for example, in a menu screen, the type of interaction with the game is
very different from when the player is solving a level or trying to survive as long as
possible. When programming a game, you have to think about how you are going
to incorporate these different game states in your game and how you will switch
between them.
Modern games will have many different game states, such as menus, maps, in-
ventories, splash screens, intro movies, and much more. In this chapter, we are going
to show how to add different game states to the Jewel Jam game. Because this game
is not yet very complicated, we can get away with using a few simple extensions
to our current classes. However, as you will see in the later game examples in this
topic, game state management is something that needs to be handled properly if we
want to build a commercial game, and later on in the topic, we will discuss a soft-
ware design using classes that can handle game states in a very nice and generic
way.
17.2 Adding a Title Screen
One of the first things we are going to do to make the game more complete is
add a title screen. The title screen allows the player to get ready for playing the
game instead of being immediately launched into it. We are going to extend the
JewelJamGameWorld class so that it loads and displays a title screen. The title screen
 
Search WWH ::




Custom Search