Game Development Reference
In-Depth Information
public function DriveSheSaid() {
init();
this.focusRect = false;
}
Keypress constants
We have created a set of constant values that represent the keyCode returned when the four
directional keys are pressed.
public static const KEY_UP:int = 38;
public static const KEY_DOWN:int = 40;
public static const KEY_LEFT:int = 37;
public static const KEY_RIGHT:int = 39;
The internal state machine
The first two variables we want to discuss are used for creating an internal Game.as state machine
that works identically like the Main.as state machine:
public static const STATE_SYSTEM_GAMEPLAY:int = 0;
public static const STATE_SYSTEM_LEVELOUT:int = 1;
private var systemFunction:Function;
private var currentSystemState:int;
private var nextSystemState:int;
private var lastSystemState:int;
The only two states we need are for the actual game play ( STATE_SYSYTEM_GAMEPLAY ) and for the
animation of the game screen move itself off of the screen during the level out sequence
( STATE_SYSTEM_LEVELOUT ). The other four variables are used to set and manipulate the state when
needed.
The tiles, display, and world
The variables for the tiles, display, and world are similar to those in the No Tanks! game but have
been modified for Drive She Said.
The mapTileHeight and mapTileWidth simply specify the height and width of a tile on tile sheet
and the world. These were called tileWidth and tileHeight in No Tanks! The display variables
are identical to the ones in No Tanks! with one exception. We have added an actual Bitmap
instance ( backgroundBitmap ) to hold the backgroundBitmapData in a separate layer in Drive She
Said. We do this so the backgroundBitmapData will not have to be redrawn each frame as we
move the camera window and repaint the screen. The world array is just a new name for the No
Tanks! array called levelTileMap . We also need new variables to specify the columns, rows,
height and width for the world because they are not the same as the canvasBitmapData (like they
were in No Tanks!).
//tiles
private var mapTileWidth:int=32;
private var mapTileHeight:int=32;
//display
private var canvasBitmapData:BitmapData;
Search WWH ::




Custom Search