Game Development Reference
In-Depth Information
Notice that our SuperClick class must extend the com.efg.framework.Game class. This will give it
use of the GAME_OVER and NEW_LEVEL constants already set up in the Game class. It will
also provide a structure of classes that can be overridden to ensure that Main.as can
communicate with the SuperClick.as properly.
We have separated the variables into three different sections. The first section governs what we
call game logic and flow. These variables are needed to make sure the game plays the way it is
designed (the game logic).
//game logic and flow
private var score:int;
private var level:int;
private var percent:Number;
private var clicked:int;
private var gameOver:Boolean;
private var circles:Array;
private var tempCircle:Circle;
private var numCreated:int;
The score variable will hold the current score accumulated by the player. The level variable
holds the current game level the player has reached. The percent variable holds the current
percentage of blue circles the player has clicked while a game level is in progress. The clicked
variable holds the number of blue circles the player has clicked during a game level. The
gameOver variable is set to false unless one of the two previously discussed GAME_OVER over
conditions occurs (see the section called “The checkForEndGame function definiton”). The
circles array holds the list of Circle class references for the current game level. We will discuss
the custom Circle class in the next section. The tempCircle variable is a class level variable that
will hold the current Circle reference while iterating through the circles array. The numCreate d
variable holds the current number of Circle instances created during a game level. Not all circles
are created at the same time, which you will see when we make use of the numCirclesOnScreen
variable.
Next up, we have messaging variables. These are used to place an instance of the custom
ScoreTextField class on to the game screen when the player clicks a blue circle. These will display
the score the player received for clicking the circle based on its size and the maxScore variable. The
scoreTexts variable will hold the current list of ScoreTextField instances that need to be displayed
on the game screen. The tempScoreText is a class level variable that will hold a reference to the
current ScoreTextField instance while iterating through the scoreTexts array. The textFormat holds
the look of the text that will be applied to the ScoreTextField instances.
After that, we have the level difficulty variables. These variables were discussed in detail inside
the game technical specification. One of these variables has been defined with a default value.
This is the maxScore variable.
private var maxScore:int = 50;
The maxScore variable is set to 50 at the beginning of the game. This is the score the player will
receive if a blue circle is clicked at its smallest size. As a Circle instance grows on the screen, its
scale will be used to adjust the maxScore to a lower amount (we say that they have an inverse
relationship).
Search WWH ::




Custom Search