aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs46
1 files changed, 20 insertions, 26 deletions
diff --git a/src/main.rs b/src/main.rs
index 3da2a33..2e45c58 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,28 +1,23 @@
-extern crate rand;
extern crate pancurses;
+extern crate rand;
extern crate text_io;
-mod state;
mod entities;
-mod world;
+mod state;
mod tiling;
+mod world;
-use entities::{Player, Character, Entity};
-use pancurses::{
- initscr,
- endwin,
- Input,
- noecho
-};
-use std::env;
+use entities::{Character, Entity, Player};
+use pancurses::{endwin, initscr, noecho, Input};
use state::State;
-use world::{Dungeon, LEFT, RIGHT, UP, DOWN};
+use std::env;
+use world::{Dungeon, DOWN, LEFT, RIGHT, UP};
fn get_player_name() -> String {
match env::var_os("USER") {
Some(val) => val.into_string().unwrap(),
- None => String::from("Kshar")
+ None => String::from("Kshar"),
}
}
@@ -30,15 +25,12 @@ fn main() {
let window = initscr();
let mut state = State::new(
- Player::new(
- get_player_name(),
- String::from("Warrior"),
- 30,
- 10,
- 10,
- 20
+ Player::new(get_player_name(), String::from("Warrior"), 30, 10, 10, 20),
+ Dungeon::new(
+ window.get_max_x() as usize,
+ (window.get_max_y() - 2) as usize,
+ 5,
),
- Dungeon::new(window.get_max_x() as usize, (window.get_max_y() - 2) as usize, 5),
);
state.init();
@@ -56,20 +48,22 @@ fn main() {
// get input and execute it
match window.getch() {
- Some(Input::Character('?')) => { window.addstr("q: quit\n"); },
+ Some(Input::Character('?')) => {
+ window.addstr("q: quit\n");
+ }
Some(Input::Character('j')) => {
state.player.move_by(DOWN).unwrap();
// state.get_player_mut().move_by(DOWN).unwrap();
- },
+ }
Some(Input::Character('k')) => {
state.get_player_mut().move_by(UP).unwrap();
- },
+ }
Some(Input::Character('h')) => {
state.get_player_mut().move_by(LEFT).unwrap();
- },
+ }
Some(Input::Character('l')) => {
state.get_player_mut().move_by(RIGHT).unwrap();
- },
+ }
Some(Input::Character('q')) => break,
Some(_) => (),
None => (),