diff options
-rw-r--r-- | src/main.rs | 9 | ||||
-rw-r--r-- | src/tiling.rs | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 2c9e611..3da2a33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,16 +15,23 @@ use pancurses::{ Input, noecho }; +use std::env; use state::State; use world::{Dungeon, LEFT, RIGHT, UP, DOWN}; +fn get_player_name() -> String { + match env::var_os("USER") { + Some(val) => val.into_string().unwrap(), + None => String::from("Kshar") + } +} fn main() { let window = initscr(); let mut state = State::new( Player::new( - String::from("Kshar"), + get_player_name(), String::from("Warrior"), 30, 10, diff --git a/src/tiling.rs b/src/tiling.rs index 3bad119..9bdb071 100644 --- a/src/tiling.rs +++ b/src/tiling.rs @@ -4,7 +4,7 @@ pub struct TileGrid { grid: Vec<Vec<TileType>> } -impl<'a> TileGrid { +impl TileGrid { pub fn new(xsize: usize, ysize: usize) -> TileGrid { let mut grid = TileGrid { grid: Vec::with_capacity(ysize) @@ -33,7 +33,7 @@ impl<'a> TileGrid { }) } - pub fn raw_data(&'a self) -> &'a Vec<Vec<TileType>> { + pub fn raw_data(& self) -> & Vec<Vec<TileType>> { &self.grid } |