Game Development Reference
In-Depth Information
These are the
map definition variables
:
//the map definition
private var tileWidth:int = 32;
private var tileHeight:int = 32;
private var mapRowCount:int = 15;
private var mapColumnCount:int = 20;
These variables define the
width
and
height
in tiles of the game screen. The
tileWidth *
mapColumnCount
equals the width of the
BitmapData
canvas for the background tile map (32
20
= 640). The
tileHeight * mapRowCount
equals the
height
of the
BitmapData
canvas for the
background tile map (32
15 = 480).
These are the
level data variables
:
private var level:int = 1;
private var levelTileMap:Array;
private var levelData:Level;
private var levels:Array = [undefined,new Level1()];
These are used by the game engine to determine which game level to display and which array to
place the data into. The
levelTileMap
will hold the background set of tiles from our game
Level1.as
file. The
levelData
variable holds a reference to the current
Level
subclass
represented by the
level
variable. The
levels
array holds a reference to all of the individual
Level
subclasses. We have only one for this game,
Level1.as
. Notice that we have added a
undefined
value in what would be
index
0
in the levels array. We do not have a level
0
on our
game, so we put this in as a placeholder. The current level's data will be accessed through a
construct like this:
levelData=levels[level];
These are the
full-screen blit variables
:
//full screen blit
private var canvasBitmapData:BitmapData=new BitmapData(tileWidth *
mapColumnCount, tileHeight * mapRowCount, true, 0x00000000);
private var canvasBitmap:Bitmap = new Bitmap(canvasBitmapData);
private var blitPoint:Point = new Point();
private var tileBlitRectangle:Rectangle = new Rectangle(0, 0, tileWidth,
tileHeight);
//***** Flex *****
private var tileSheet:TileSheet= new TileSheet(new
Library.TankSheetPng().bitmapData,tileWidth, tileHeight);
//***** End Flex *****
//***** Flash IDE *****
//private var tileSheet:TileSheet = new TileSheet(new
TankSheetPng(0,0), tileWidth, tileHeight);
//***** End Flash IDE *****
These variables are used to display the background tiles for the level with blitting operations. The
canvasBitmapData
defines a
BitmapData
object that will hold the 20
15 set of painted tiles for the
game
TILE_MOVE
and
TILE_WALL
tiles. This is what we call the
full-screen blit canvas
. The
canvasBitmap
is the actual display object that will be added to the stage display list.