Game Development Reference
In-Depth Information
}
if ( bmd != null ) {
graphics.beginBitmapFill(bmd);
graphics.drawRect(0, 0, bmd.width, bmd.height);
graphics.endFill();
}
}
The space station is the sprite that gets displayed when the ships reach the finish line.
The items' update method simply updates the x coordinate of the item, depending on
the speed of the ship. This is what gives the illusion that the ship is moving and
with speed.
The following update method is called on each item's object that's loaded by its
quadrant. The speed passed in is the current speed of the ship.
public function update(speed:Number):void {
x -= speed;
}
The items are created when the quadrant is loaded. Here is the load method of the
quadrant and the initItems method:
public function load(p:GameClient):Boolean {
if ( m_loaded )
return false;
m_loaded = true;
if ( m_objects.length == 0 )
initItems(p);
trace("Loaded Q:" + m_id);
return true;
}
public function initItems(p:GameClient):void {
var i:int;
if ( m_objects.length > 0 )
return; // another client has already loaded it
for ( i=0; i<(m_id+1); i++ ) {
var ic:ItemClient;
var item:Item;
var sx:Number, sy:Number;
item = new Item(m_id, m_itemId, Item.BLACK_HOLE);
sx = ((Math.random()*1000000)%RaceTrack.QUADRANT_
LENGTH)+800;
sy = (Math.random()*1000000)%600;
 
Search WWH ::




Custom Search