Game Development Reference
In-Depth Information
objects than we did Block objects in Color Drop with a total of 30 (5 rows and 6 columns). Other
than that, the specific changes to the variables are for display only.
package com.efg.games.dicebattle
{
import flash.display.Sprite;
import flash.events.*;
import com.efg.framework.Game;
import com.efg.framework.CustomEventLevelScreenUpdate;
import com.efg.framework.CustomEventScoreBoardUpdate;
import com.efg.framework.CustomEventSound;
import com.efg.framework.TileSheet;
public class DiceBattle extends Game
{
private var gameWidth:int;
private var gameHeight:int;
private static const Y_PAD:int = 75;
private static const X_PAD:int = 150;
private static const ROW_SPACING:int = 4;
private static const COL_SPACING:int = 4;
private static const DIE_HEIGHT:int = 50;
private static const DIE_WIDTH:int = 50;
private static const DIE_ROWS:int = 5;
private static const DIE_COLS:int = 6;
The first significant differences in the class are CHAR_WIDTH and CHAR_HEIGHT. These two
variables define the size of the character tiles that we will cut from the Characters tile sheet. We
will use these in the init function. The next new variables will hold the hit points for both the player
( playerLife ) and the computer ( computerLife ). We will report these values back to the
scoreboard with our custom event so they can be displayed properly. turn is a text variable that
will hold the text for the current turn (Player Turn or Computer Turn). These values are held in the two
static constants, TURN_PLAYER and TURN_COMPUTER. We will use this for both display and
a logic test in our state switch statement.
private static const CHAR_WIDTH:int = 64;
private static const CHAR_HEIGHT:int = 64;
private var score:int;
private var level:int;
private var playerLife:int;
private var computerLife:int;
private var turn:String;
private static const TURN_PLAYER:String = "Player's";
private static const TURN_COMPUTER:String = "Computer's";
private var difficultyLevelArray:Array;
private var currentLevel:DifficultyLevel;
Search WWH ::




Custom Search