Game Development Reference
In-Depth Information
The
tileWidth
and
tileHeight
are passed directly into the constructor.
private var tileWidth:int;
private var tileHeight:int;
In the constructor, they are assigned.
this.tileHeight = tileHeight;
this.tileWidth = tileWidth;
The
tilesPerRow
variable is very important for our blitting operations. It is used to calculate the
row and column values for the needed tile based only on the location of the tile in a single
dimensional array. For example, to locate the tile number 9 on the tile sheet, with a
tilesPerRow
value of
8
, we find that we must look for the first tile on the second row of our tile sheet.
private var tilesPerRow:int;
That's all there is to the
TileSheet
class. Let's move on to reading the level data from our
Level1.as
class.
Reading the level data
All of the data for our level will reside in a class, just like the tile sheet data. We do this so our
game can be distributed on a single SWF file and to make game portal integration very easy. We
have a very basic base class for all of the No Tanks! levels called
Level
. Let's start by creating
this class.
The Level class
The
Level
class will be the base class for all of the game levels we create. It will be created inside
the No Tanks! package structure:
The Flash IDE:
/source/projects/notanks/flashIDE/com/efg/games/notanks/Level.as
The Flex SDK (using Flash Develop)
/source/projects/notanks/flexSDK/src/com/efg/games/notanks/Level.as
Here is the complete code for the
Level.as
class:
package com.efg.games.notanks
{
/**
* ...
* @author Jeff Fulton
*/
public class Level {
public var backGroundMap:Array;
public var spriteMap:Array;
public var backGroundTile:int;
public var enemyIntelligence:int;
public var enemyShotSpeed:Number;
public var ammoPickUp:int;