aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorGuillaume Pasquet <dev@etenil.net>2019-11-19 04:56:57 +0000
committerGuillaume Pasquet <dev@etenil.net>2019-11-19 04:56:57 +0000
commit138b22aec818572e88e1cc254301dc4a844784b0 (patch)
tree1331cdecbe63630d897e8de4867fd358832ac913 /src/main.rs
parent649e209c64a86e951bf24805e369143888f33c9a (diff)
Let's set boundaries.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index c8e3133..0351ffb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,5 @@
extern crate crossterm;
+extern crate ignore_result;
extern crate rand;
extern crate text_io;
@@ -12,7 +13,8 @@ use crossterm::input::{input, InputEvent, KeyEvent};
use crossterm::screen::{EnterAlternateScreen, LeaveAlternateScreen, RawScreen};
use crossterm::terminal;
use crossterm::{execute, Output};
-use entities::{Entity, Player};
+use entities::Player;
+use ignore_result::Ignore;
use state::State;
use std::env;
use std::io::{stdout, Write};
@@ -59,15 +61,15 @@ fn main() {
InputEvent::Keyboard(KeyEvent::Char('?')) => {
execute!(stdout(), Output("q: quit")).unwrap()
}
- InputEvent::Keyboard(KeyEvent::Char('j')) => state.player.move_by(DOWN).unwrap(),
- InputEvent::Keyboard(KeyEvent::Char('k')) => state.player.move_by(UP).unwrap(),
- InputEvent::Keyboard(KeyEvent::Char('h')) => state.player.move_by(LEFT).unwrap(),
- InputEvent::Keyboard(KeyEvent::Char('l')) => state.player.move_by(RIGHT).unwrap(),
+ InputEvent::Keyboard(KeyEvent::Char('j')) => state.move_player(DOWN).ignore(),
+ InputEvent::Keyboard(KeyEvent::Char('k')) => state.move_player(UP).ignore(),
+ InputEvent::Keyboard(KeyEvent::Char('h')) => state.move_player(LEFT).ignore(),
+ InputEvent::Keyboard(KeyEvent::Char('l')) => state.move_player(RIGHT).ignore(),
// Arrow keys for noobs
- InputEvent::Keyboard(KeyEvent::Down) => state.player.move_by(DOWN).unwrap(),
- InputEvent::Keyboard(KeyEvent::Up) => state.player.move_by(UP).unwrap(),
- InputEvent::Keyboard(KeyEvent::Left) => state.player.move_by(LEFT).unwrap(),
- InputEvent::Keyboard(KeyEvent::Right) => state.player.move_by(RIGHT).unwrap(),
+ InputEvent::Keyboard(KeyEvent::Down) => state.move_player(DOWN).ignore(),
+ InputEvent::Keyboard(KeyEvent::Up) => state.move_player(UP).ignore(),
+ InputEvent::Keyboard(KeyEvent::Left) => state.move_player(LEFT).ignore(),
+ InputEvent::Keyboard(KeyEvent::Right) => state.move_player(RIGHT).ignore(),
_ => (),
}
}