Game Development Reference
In-Depth Information
The GameFrameWork.as class
The GameFrameWork.as class is the foundation of the framework. It contains a simple state
machine and a basic game loop timer. Our state machine is a simple construct containing a set of
state constants to switch the framework between states. States are handled by state functions
inside the GameFrameWork.as file. We will employ a variable to reference the current state
function. The game timer will use this refernce to call the current state function on each frame
tick. We will create states for such things as the title screen, instructions screen, game play,
game over, and more.
When we create a new game our document class will be an instance of GameFrameWork called
Main.as . This Main.as will have an init (short for “initialization”) function that will set up the
framework for use. This Main.as class will also act as a sort of message gateway between the
game and the framework classes. If you are confused, don't worry; we'll be explaining this in
greater detail soon.
The FrameWorkStates.as class
This FrameWorkStates.as class will simply contain a set of constant integer values representing
the state machine states. When we first create the framework we will have 10 different state
constants. All will begin with the STATE_SYSTEM designation. For example, we will have a state that
displays the title screen. The state constant for this will be STATE_SYSTEM_TITLE . More states will
be added as we progress through the chapters in this topic.
The BasicScreen class and SimpleBlitButton helper class
The BasicScreen class will be used to display very simple game state screens. These screens
can have a basic background color with transparency (if needed), as well as some text centered
on the screen. Each screen can also have a button that needs to be clicked to move to a new
state in the state machine. This class is so simple that it will probably never be used without
major modification in your own commercial games. We present it here, in its very simple form, for
utility purposes.
The SimpleBlitButton helper class is used to create a clickable button with rollover and off
states. The button is created completely in code with a simple color background for the over and
off states to be sed in the BasicScreen class. We do this for simplicity and to demonstrate some
Sprite blitting techniques (much more on these later in the topic) using a set of BitmapData
instances for the background color change of the button on rollover.
The ScoreBoard class and SideBySideScoreElement
helper class
The ScoreBoard class displays information for the user during game play. Data such as the
current game score, time remaining, and other useful information can be displayed to the user
with a very basic look and feel by using this class. It can be used as is, but when you start to
make your own commercial games, you might find it useful to extend this class with more
functionality. This very basic class is used inside the framework to demonstrate how to use
events from a Game instance to update a game score board.
Search WWH ::




Custom Search