Game Development Reference
In-Depth Information
graphics.beginFill(0x00FF00, 0.4);
graphics.drawEllipse(0, 0, WIDTH, HEIGHT);
graphics.endFill();
// Center it and put it at the bottom
// of the screen
x = (RaceTrack.SCREEN_W/2 - WIDTH/2);
y = RaceTrack.SCREEN_H - HEIGHT;
}
public function update(a:Astroid):void {
// avoid drawing stuff thats
// still far away from the ship
if ( a.x > RaceTrack.SCREEN_W*2 )
return;
// remove the ones that have passed
if ( a.x < 0 ) {
s = m_map.getValue(a.getKey());
if ( s != null )
m_map.remove(a.getKey());
return;
}
var s:Sprite;
s = m_map.getValue(a.getKey());
if ( s == null ) {
// new astroid
s = new Sprite();
m_map.put(a.getKey(), s);
// simple black circle
s.graphics.beginFill(0x000000, 0.7);
s.graphics.drawCircle(0, 0, 3);
s.graphics.endFill();
addChild(s);
}
// draw it at a proportional
// x and y within the radar screen
var c:Number = a.x;
var l:Number = RaceTrack.SCREEN_W*2;
var p:Number = c/l;
s.x = p*WIDTH;
c = a.y;
l = RaceTrack.SCREEN_H;
p = c/l;
s.y = p*HEIGHT;
}
}
}
 
Search WWH ::




Custom Search