Game Development Reference
In-Depth Information
percentNeededLabel
: Displays % needed
percentNeededText
: Displays the percent of blue circles needed per level value
SCORE_BOARD_PERCENT_ACHIEVED
: The
scoreBoard
name constant in
Main.as
for the
percent achieved display
percentAchievedLabel
: Displays % achieved
percentAchievedText
: Displays the value representing the percent of blue circles clicked
Describing the game play and flow
The game is split into a series of levels with ever increasing difficulty. A level will start by
randomly placing circles on to the game screen until
circle.length == maxCirclesOnscreen
. As
circles are created,
the
percentBadCircles
variable will be used to determine whether to create a
good (blue) or bad (red) circle. Circles will grow at the
circleGrowSpeed
rate. This will increase
the
scaleX
and
scaleY
values for the
Circle
instance on each frame tick.
The player must click as many blue circles as possible before the circles reach
circleMaxSize
.
The smaller a
Circle
, the more points the player will receive for clicking it. If the player does not
click a
Circle
before it reaches
circleMaxSize
, it will leave the screen.
When a
Circle
is clicked or leaves the screen because it reached
circleMaxSize
, a new circle
will be created to replace it if the
numCreated
variable is less than the
numCircles
variable.
When a good
Circle
instance is clicked, the
Circle
will fade out, and a text field containing the
score the player received will be displayed close to the
Circle
.
Evaluating the end of a level
A game level is over when all of the circles (
numCircles
) have been displayed on the screen. The
logic will also need to make sure that there are no
Circle
instances in the circles array before the
level can be considered over.
If the circle array length is 0 and number of circles created so far is equal to the number of circles
required for the level, the level is complete. (
aCircle.length == 0 && numCreated ==
numCircles
).
Evaluating the end of a game
The game is over when the player clicks a red circle at any time or completes a level without
clicking enough blue circles (that is, if the percentage clicked is not greater than or equal to
percentNeeded
).
Defining the necessary events
Events are used throughout the framework to signify changes to the state of the game and to
update the
scoreboard
instance and the
levelInScreen
. We split events into two different
categories. The first are
simple custom events
. These are simply
String
constants that will be
passed to the standard
dispatchEvent
function call. They are not used to pass any data to the
listening function. The second type of events we will use are called
complex custom events
.
These make use of the customized
Event
classes created in Chapter 2 and have the ability to
pass data to the listening functions.