Game Development Reference
In-Depth Information
Figure 1-9. PlayerImage, EnemyImage, MissileImage
Pixel Shooter sounds
We will use two sounds for the game, and both will go into the .swf library and will be exported as
the following classes:
Explode : An explosion sound for when the aliens are destroyed
Shoot : The sound of the pixel ship's cannon
Pixel Shooter code
The entire code listing for Pixel Shooter follows. Since we used Balloon Saw as the basis for Pixel
Shooter, we have highlighted the code that is different from that game.
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.*;
import flash.events.*;
import flash.geom.Rectangle;
import flash.media.Sound;
import flash.text.*;
public class Game extends flash.display.MovieClip{
public static const STATE_INIT:int = 10;
public static const STATE_START_PLAYER:int = 20;
public static const STATE_PLAY_GAME:int = 30;
public static const STATE_REMOVE_PLAYER:int = 40;
public static const STATE_END_GAME:int = 50;
public var gameState:int = 0;
public var score:int = 0;
public var chances:int = 0;
public var bg:MovieClip;
public var enemies:Array;
public var missiles:Array;
public var explosions:Array;
public var player:MovieClip;
public var level:Number = 0;
public var scoreLabel:TextField = new TextField();
public var levelLabel:TextField = new TextField();
public var chancesLabel:TextField = new TextField();
public var scoreText:TextField = new TextField();
Search WWH ::




Custom Search