aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Ferro <luis.ferro@eggplant.io>2019-11-12 11:12:32 +0100
committerLuis Ferro <luis.ferro@eggplant.io>2019-11-12 11:12:32 +0100
commit5175eecf982b817191b32ef031269808ceb23710 (patch)
tree422f2e4e22d4092be0fbb2a1f3ed075108156b43
parent54b3362a04cbe607232c2a00edd61b5c948bb31e (diff)
Add main loop for input and placeholder locations for dungeon / game state changes.
-rw-r--r--src/main.rs23
-rw-r--r--src/world.rs3
2 files changed, 22 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index e5fe385..4426a93 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,7 +12,7 @@ use std::env;
use character::Player;
use character::Character;
use computer::Enemy;
-use pancurses::{Window, initscr, endwin};
+use pancurses::{Window, initscr, endwin, Input, noecho};
use world::{Dungeon, Level, Generable, TileType};
fn tile_to_str(tile: &TileType) -> &str {
@@ -22,6 +22,7 @@ fn tile_to_str(tile: &TileType) -> &str {
TileType::Empty => " ",
TileType::StairsDown => ">",
TileType::StairsUp => "<",
+ TileType::Character => "@",
_ => "?"
}
}
@@ -85,8 +86,24 @@ fn main() {
let window = initscr();
render_level(&window, &dungeon.levels[0]);
- window.refresh();
- window.getch();
+ loop {
+ // update actors
+ // update character
+ window.refresh();
+
+ // get input and execute it
+ match window.getch() {
+
+ Some(Input::Character('h')) => { window.addstr("DEL: quit\n"); },
+ // Some(Input::KeyDown) => { window.addstr("down\n"); },
+ // Some(Input::KeyUp) => { window.addch('b'); },
+ // Some(Input::KeyLeft) => { window.addch('c'); },
+ // Some(Input::KeyRight) => { window.addch('d'); },
+ Some(Input::KeyDC) => break,
+ Some(_) => (),
+ None => (),
+ }
+ }
endwin();
}
diff --git a/src/world.rs b/src/world.rs
index 23bed8a..24a4c31 100644
--- a/src/world.rs
+++ b/src/world.rs
@@ -8,7 +8,8 @@ pub enum TileType {
Wall,
Floor,
StairsUp,
- StairsDown
+ StairsDown,
+ Character,
}
enum CorridorType {