Game Development Reference
In-Depth Information
private var backgroundBitmapData:BitmapData;
private var canvasBitmap:Bitmap;
private var backgroundBitmap:Bitmap;
//world
private var world:Array=new Array();
private var worldCols:int=50;
private var worldRows:int=50;
private var worldWidth:int=worldCols*mapTileWidth;
private var worldHeight:int=worldRows*mapTileHeight;
The camera
The camera is simply an instance of the Camera2D class that we discussed earlier:
//camera
private var camera:Camera2D = new Camera2D();
Car sounds
The car sounds are going to be handled in a unique manner. Based on the velocity of the player
car, we will loop the car sound with a different wait between plays: The faster the car's velocity,
the shorter the wait (in milliseconds).
//*sounds
private var carSoundDelayList:Array = [90,80,70,60,50,40,30,20,15,10,0];
private var carSoundTime:int = getTimer();
The carSoundDelay array holds the number of milliseconds between plays of the car's sound. For
example, at velocity 0 (car idle), there is a 90-millisecond delay between plays of the car sound.
Creating a working class (hero?) in iteration 2
In this iteration, we will add enough code to the DriveSheSaid.as to allow us to compile the
application and see it fire the runGame function repeatedly. We are going to create stub functions
for all of the in-game processes. We are also going to setup and begin use of the internal state
machine. Simply add all of this under the constructor:
private function init():void {}
override public function newGame():void {
switchSystemState( STATE_SYSTEM_GAMEPLAY );
}
override public function newLevel():void {
stage.focus = this;
}
private function restartPlayer():void {}
private function updateScoreBoard():void {}
override public function runGame():void {
systemFunction();
}
Search WWH ::




Custom Search