Game Development Reference
In-Depth Information
public function Level() {
}
}
}
This is a simple base class that only defines the variables that will be needed to store all of the
data for each game level. Let's take a look at each variable.
public var backGroundMap:Array;
The backGroundMap array will store the 2D array of level data we created in Mappy for the
background layer (layer 0) for the game level.
public var spriteMap:Array;
The spriteMap array will store the 2D array of level data we created in Mappy for the sprite layer
(layer 1) for the game level.
public var backGroundTile:int;
The backGroundTile variable is used to tell the game engine which tile on the tile sheet should be
ignored when drawing the sprite layer. Normally, this will be tile 0. If you recall, Mappy used tile 0
as tile ID for the blank tiles on the sprite layer. We will use 0 in our game, but if you use a different
level editor, you might need to change this value.
public var enemyIntelligence:int;
The enemyIntellgence value is a number from 0-100. It is used to tell the game engine how often
(in percentages) that the enemy will make a random movement rather than follow the rules of the
tile-base chase AI we will cover in the next chapter. The higher the number the more intelligent
the enemy will be.
public var enemyShotSpeed:Number;
The enemyShotSpeed is the number of pixels that the enemy missiles will travel per frame tick. The
greater this number the faster the enemy shots will travel.
The ammoPickUp variable is the amount of ammunition that will be added to the player's reserves
when an ammunition pickup sprite is collected.
Creating the Level1 class
The class that will hold our level 1 data is called Level1.as . This file will be part of the No Tanks!
package structure. It will be a subclass of the Level class with the variables assigned to specific
values for our game level.
This is the path for the Flash IDE:
[source][projects][notanks][flashIDE][com][efg][games][notanks]Level1.as
And here's the one for the Flex SDK (using Flash Develop):
[source][projects][notanks][flexSDK][src][com][efg][games] [notanks]Level1.as
Search WWH ::




Custom Search