Game Development Reference
In-Depth Information
Now we will define some very important const values that we will use for this game. These are
also some of the more important values to understand if you want to reuse this game for another
purpose, as they help define the position, size, and spacing of the grid of Blocks on the screen.
//Game Constants
The first two constants are X_PAD and Y_PAD. These two values define the starting (x, y)
position of the grid of Blocks on the screen. These values will be added to the position of every
Block when it is created so that it will be positioned correctly
private static const Y_PAD:int = 50;
private static const X_PAD:int = 135
ROW_SPACING and COL_SPACING define how many pixels of empty space we will leave in
between each block on the screen.
private static const ROW_SPACING:int = 2;
private static const COL_SPACING:int = 2;
BLOCK_HEIGHT and BLOCK_WIDTH define the dimensions of each Block. These will also be used
when we create our TileSheet object to define the dimensions of each tile.
private static const BLOCK_HEIGHT:int= 32;
private static const BLOCK_WIDTH:int = 32;
BLOCK_ROWS and BLOCK_COLS define how many rows and columns of blocks will appear on the
screen. The way this game is written, you can easily change the amount of blocks on the screen
by updating these values.
private static const BLOCK_ROWS:int = 10;
private static const BLOCK_COLS:int = 10;
The next set of variables is used for in-game housekeeping. We already described these values
when we discussed the additions to the ScoreBoard in Main, but to review
score is the player's total game score that we will report back to ScoreBoard .
level is the current game level we will report back to ScoreBoard .
plays are the number of clicks the player has left, which we will also report back to
ScoreBoard .
levelScore is the current accumulated score for this level that we report back to ScoreBoard .
This score must be equal to or higher than DifficultyLevel.scoreThreshhold before plays
have been exhausted for the player to advance to the next level.
private var score:int;
private var level:int;
private var plays:int;
private var levelScore:int;
Since we are going to manage the game's difficulty using DifficultyLevel objects stored in an
array, we need to define some variable to hold these values. difficultyLevelArray will hold all of
the DifficultyLevel objects we create. currentLevel will hold the DifficultyLevel class that
represents the level the player is currently playing.
private var difficultyLevelArray:Array;
private var currentLevel:DifficultyLevel;
Search WWH ::




Custom Search