Browse Source

Add WASD keys

master
Garrit Franke 3 years ago
parent
commit
a11e45ec2e
  1. 9
      src/main.rs

9
src/main.rs

@ -132,6 +132,12 @@ impl GameState for State {
VirtualKeyCode::Left => self.move_player(Point::new(-1, 0)),
VirtualKeyCode::Right => self.move_player(Point::new(1, 0)),
// L33t keys
VirtualKeyCode::W => self.move_player(Point::new(0, -1)),
VirtualKeyCode::S => self.move_player(Point::new(0, 1)),
VirtualKeyCode::A => self.move_player(Point::new(-1, 0)),
VirtualKeyCode::D => self.move_player(Point::new(1, 0)),
_ => {} // Ignore all the other possibilities
}
}
@ -214,7 +220,8 @@ impl Algorithm2D for State {
}
fn main() -> RltkError {
let context = RltkBuilder::simple80x50()
let context = RltkBuilder::simple(80, 70)?
.with_automatic_console_resize(true)
.with_title("Tales of Midgard")
.build()?;
let gs = State::new();

Loading…
Cancel
Save