Game Development Reference
In-Depth Information
public class TileByTileBlitSprite extends BlitSprite {
public var inTunnel:Boolean = false;
public var currRow:int;
public var currCol:int;
public var nextRow:int;
public var nextCol:int;
public var moveDirectionsToTest:Array = [];
public var missileDelay:Number = 100;
public var missileTime:int;
public var healthPoints:int;
public var distinationX:Number;
public var distinationY:Number;
public var currDirection:int = 0;
public var moveSpeed:Number = 2;
public var currentRegion:int;
public function TileByTileBlitSprite(tileSheet:TileSheet, tileList:Array,
firstFrame:int) {
super(tileSheet, tileList, firstFrame);
}
}
}
The TileByTileBlitSprite class very well could have just been part of the BlitSprite class, but
by creating another class, we can make use of the BlitSprite class for non-tile-based games
and without the slight overhead of the extra variables that would be unnecessary. Also, I added
the healthPoints variable to this class because it is only needed for the player and enemy tanks.
We will examine the use of all of these variables as we proceed through this chapter.
Moving the player character through the maze
We are going to create a system of movement for the player that will allow level designers the
freedom to not worry about where they place tiles. By this, I mean we will have very few preset
rules for creating a level. As long as a level contains TILE_WALL and TILE_MOVE tiles, a green
Player tank, and a Goal , it should work without a problem. We won't set any other rules for level
design. This will be similar to the methods employed by platform game engine designers.
Most classic versions of maze/chase games were created in such a way that preset math and
logic were used to set the directions that a player or other character could move at intersections
in the maze. This hard-coded information was used to simplify the math needed to turn the
characters in the right directions and restrict allowable movement to the open corridors in the
maze. You will see this type of logic coding if you Google Java and JavaScript versions of Pac-
Man code. The classic Pac-Man game had only a single maze, so hard-coding movement logic
made sense. We want our game engine to be extensible with as many different levels as
possible, so we have chosen a different, more fluid method to code our movement logic.
Search WWH ::




Custom Search