-
Notifications
You must be signed in to change notification settings - Fork 9
LineOfSight
Will Blanton edited this page Sep 13, 2019
·
1 revision
A Haxe implementation of a line of sight algorithm from roguebasin
Usage:
using LineOfSight;
class Main
{
static function main()
{
var map_data = [
' ######## '.split(''),
' #......# '.split(''),
' #......# '.split(''),
' #......####### '.split(''),
' ####.####....# '.split(''),
' #..........# '.split(''),
' #...###....# '.split(''),
' ##### ###### '.split(''),
];
var los = new LineOfSight({ map: map_data, walls: ['#'] });
var p = { x: 5, y: 5 };
los.fov(p.x, p.y, 6);
for (row in los.place_char(los.get_lit_map('?'), '@', p)) trace(row.join(''));
}
}
Output:
???#####????????
????...?????????
????...?????????
????...?????????
??###.####.?????
#.@.....?????
?? #...###.?????
???#####????????
For more info, please check out the API: http://01010111.com/zerolib/