Game Development Reference
In-Depth Information
//draw playfield as two simple lines at top and bottom of screen
playfieldShape.graphics.clear();
playfieldShape.graphics.lineStyle(2, 0xffffff);
playfieldShape.graphics.moveTo(playfieldminX, playfieldminY);
playfieldShape.graphics.lineTo(playfieldmaxX, playfieldminY);
playfieldShape.graphics.moveTo(playfieldminX, playfieldmaxY);
playfieldShape.graphics.lineTo(playfieldmaxX, playfieldmaxY);
playfieldSprite.addChild(playfieldShape);
}
private function createObstaclePool():void {
for (var ctr:int = 0; ctr < obstaclePoolLength; ctr++) {
var tempBitmapData:BitmapData =
new BitmapData(1, 1, false, obstacleColors[obstacleColorIndex]);
var tempObstacle:Bitmap = new Bitmap(tempBitmapData)
obstaclePool.push(tempObstacle);
}
}
private function createExhaustPool():void {
//create look for exhaust
var tempBD:BitmapData = new BitmapData(32, 32, true, 0x00000000);
tempBD.setPixel32(30, 15, 0xffff00ff);
tempBD.setPixel32(28, 15, 0xffff00ff);
tempBD.setPixel32(27, 15, 0xffff00ff);
var tempBlitArrayAsset:BlitArrayAsset= new BlitArrayAsset();
tempBlitArrayAsset.createFadeOutBlitArrayFromBD(tempBD, 20);
exhaustAnimationList = tempBlitArrayAsset.tileList;
for (var ctr:int = 0; ctr < exhaustPoolLength; ctr++) {
var tempExhaustParticle:BasicBiltArrayParticle =
new BasicBiltArrayParticle(playfieldminX, playfieldmaxY,
playfieldminY, playfieldmaxY);
exhaustPool.push(tempExhaustParticle);
}
}
private function setUpCanvas():void {
canvasBitmapData.lock();
canvasBitmapData.copyPixels(backgroundBitmapData, backgroundBitmapData.rect, blitPoint);
canvasBitmapData.unlock();
}
The following code sets up a new game and level . The newGame function resets all of the game
variables such as those that define the size, and frequency of the obstacles. The newLevel
function sets the player on the screen, starts up the in game music and resets the obstacle
frequency counters. There is only one level in this version of the game, but if we wanted to add
more levels this function affectively separates the newGame specific functions from the newLevel
specific functions.
override public function newGame():void {
score = 0;
obstacleColorIndex = 0;
Search WWH ::




Custom Search