Game Development Reference
In-Depth Information
s.y = 4;
addChild(s);
}
var c:Number = ship.getCoord(); //universe coord
var l:Number;
l = RaceTrack.QUADRANT_LENGTH*RaceTrack.QUADRANT_COUNT;
var p:Number = c/l; // how much the ship has covered
var pos:Number = p*MAP_LEN; //scale it to map
s.x = pos; // update the sprite's x
}
}
}
The method update is repeatedly called within the main loop in RaceTrack object for
each ship currently in race.
The Radar class
Radar, like the mini-map, is a simple implementation to show the coming asteroids.
The player will be able to see them before they are visible on the screen enabling
players to dodge them better. The radar class also has an update method that
gets called from within the main game loop.
Here is the listing for the class:
package race.game
{
import flash.display.Sprite;
import pulseui.util.Map;
import race.AstroRace;
import race.game.Astroid;
public class Radar extends Sprite
{
// Size of the radar display
private const WIDTH:Number = 200;
private const HEIGHT:Number = 35;
// Hashmap of items currently displayed
private var m_map:Map = new Map();
public function Radar()
{
super();
// make a green eclipse
 
Search WWH ::




Custom Search