extern crate rand;
extern crate tcod;
use tcod::{Console, RootConsole, BackgroundFlag, Map};
use tcod::map::FovAlgorithm;
#[derive(Copy, Clone)]
pub struct Tile {
ch: char,
x: i32,
y: i32,
}
fn main() {
let mut root = RootConsole::initializer().size(40, 40) .title("FOV example").init();
let mut map = Map::new(40,40);
let mut tiles = Vec::new();
root.clear();
for x in 0..40 {
for y in 0..40 {
if rand::random() {
tiles.push(Tile{x:x, y:y, ch: '#' });
map.set(x,y,false,false);
} else {
tiles.push(Tile{x:x, y:y, ch: '.'});
map.set(x,y,true,true);
}
}
}
map.compute_fov(20,20, 10, true, FovAlgorithm::Basic);
for tile in tiles.iter() {
if map.is_in_fov(tile.x, tile.y) {
root.put_char(tile.x,tile.y,tile.ch, BackgroundFlag::Set);
}
}
root.put_char(20,20, '@', BackgroundFlag::Set);
root.flush();
root.wait_for_keypress(true);
}