Game Development Reference
In-Depth Information
Implementing items
Let's now look at the implementation of items in the game. There are three kinds of
items in the game; visually you will see them as either black holes, mushrooms, or
asteroids. It's quite easy to extend them as per your game design. Currently, except
for asteroids there is no effect on the ship when it collides with the items. The two
items, black holes and mushrooms, are typed instead of being subclassed, as they are
quite simple. Asteroids, on the other hand, have the effect of cutting down the speed
of the ship down to a minimum, unless the shields are active on the ship.
The constructor of the Item class is as follows:
public function Item(index:int, q:int, type:int)
{
super();
m_index = index;
m_quadrant = q;
m_type = type;
var bma:BitmapAsset = null;
var bmd:BitmapData = null;
switch (type) {
case BLACK_HOLE:
bma = new BHClass() as BitmapAsset;
bmd = bma.bitmapData;
break;
case MUSHROOM:
bma = new MushClass() as BitmapAsset;
bmd = bma.bitmapData;
break;
case SPACE_STATION:
bma = new EndClass() as BitmapAsset;
bmd = bma.bitmapData;
break;
Search WWH ::




Custom Search