Game Development Reference
In-Depth Information
Coding the TunnelPanic.as class
This section shows the complete code for the Game.as class and subclasses. As you will see, we
have discussed much of the code and algorithms already.
The class shell includes the class import section, the variable definition section and the class
constructor: We have taken a look at most of the variables already, and the rest of the shell consists
of the constructor that calls the init function and the closing brackets for the class and package.
package com.efg.games.tunnelpanic
{
import flash.display.*
import flash.events.*;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.utils.getTimer;
import com.efg.framework.BasicBlitArrayObject;
import com.efg.framework.BlitArrayAsset;
import com.efg.framework.BasicBiltArrayParticle;
import com.efg.framework.CustomEventLevelScreenUpdate;
import com.efg.framework.CustomEventScoreBoardUpdate;
import com.efg.framework.CustomEventSound;
import com.efg.framework.Game;
public class TunnelPanic extends com.efg.framework.Game
{
public static const STATE_SYSTEM_GAME_PLAY:int = 0;
public static const STATE_SYSTEM_PLAYER_EXPLODE:int = 1;
private var systemFunction:Function;
private var currentSystemState:int;
private var nextSystemState:int;
private var lastSystemState:int;
private var customerScoreBoardEventScore:CustomEventScoreBoardUpdate
= new CustomEventScoreBoardUpdate(CustomEventScoreBoardUpdate.UPDATE_TEXT,
Main.SCORE_BOARD_SCORE, "");
//Tunnel Panic game specific
private var keyPressList:Array = [];
private var keyListenersInit:Boolean = false;
//player ship
private var playerSprite:Sprite = new Sprite();
private var playerShape:Shape = new Shape();
private var playerSpeed:Number = 4;
private var playerStarted:Boolean = false;
//playfield
private var playfieldSprite:Sprite = new Sprite();
private var playfieldShape:Shape = new Shape();
Search WWH ::




Custom Search