forked from noio/kingdom
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Minimap.as
executable file
·57 lines (49 loc) · 1.74 KB
/
Minimap.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxG;
import org.flixel.FlxBasic;
import org.flixel.FlxGroup;
public class Minimap extends FlxSprite{
public var members:Array = [];
public var colors:Array = [];
public function Minimap(X:Number=0, Y:Number=0, w:int=100, h:int=10){
super(X, Y);
scrollFactor.x = scrollFactor.y = 0;
makeGraphic(w,h,0,true);
}
public function add(member:FlxBasic, color:uint=0xFFFF0000):void{
members.push(member);
colors.push(color);
}
override public function draw():void{
fill(0x55000000);
for (var i:int = 0; i < members.length; i++){
drawDot(members[i], colors[i]);
}
dirty = true;
super.draw();
}
public function drawDot(m:FlxBasic, color:uint):void{
if (m is FlxGroup){
var group:FlxGroup = m as FlxGroup;
for (var i:int = 0; i < group.length; i++){
drawDot(group.members[i], color);
}
}
else if (m is FlxSprite){
if (!m.alive || !m.visible){
return;
}
if (m is Wall && (m as Wall).stage == 0){
return;
}
var sprite:FlxSprite = m as FlxSprite;
var ex:int = (sprite.x / FlxG.worldBounds.width) * this.width;
var ey:int = (sprite.y / FlxG.worldBounds.height) * this.height;
this.pixels.setPixel32(ex, ey, color);
}
}
}
}