extern crate tcod;
use tcod::{Console, RootConsole, BackgroundFlag};
use tcod::input::Key;
use tcod::input::KeyCode::{Up, Down, Left, Right, Escape};
fn main() {
let mut con = RootConsole::initializer()
.size(80, 50)
.title("libtcod Rust tutorial")
.init();
let mut x = 40;
let mut y = 25;
while !con.window_closed() {
con.clear();
con.put_char(x, y, '@', BackgroundFlag::Set);
con.flush();
let keypress = con.wait_for_keypress(true);
if keypress.pressed {
match keypress {
Key { code: Escape, .. } => break,
Key { code: Up, .. } => y -= 1,
Key { code: Down, .. } => y += 1,
Key { code: Left, .. } => x -= 1,
Key { code: Right, .. } => x += 1,
_ => {}
}
}
}
}