diff options
| -rw-r--r-- | src/entities.rs | 31 | ||||
| -rw-r--r-- | src/main.rs | 19 | 
2 files changed, 46 insertions, 4 deletions
| diff --git a/src/entities.rs b/src/entities.rs index 51cefc1..c3ec262 100644 --- a/src/entities.rs +++ b/src/entities.rs @@ -13,12 +13,13 @@ pub struct Character {      pub name: String,
      pub class: String,
      pub health: i32,
 +    pub level: i32,
 +    pub location: Point,
      max_health: i32,
      attack: i32,
      dodge: i32,
      luck: i32,
      xp: i32,
 -    location: Point,
      tile_type: TileType
  }
 @@ -29,6 +30,7 @@ pub trait Enemy {          attack: i32,
          dodge: i32,
          luck: i32,
 +        level: i32,
          location: Point
      ) -> Self;
 @@ -102,7 +104,9 @@ impl Player for Character {          attack: i32,
          dodge: i32,
          luck: i32,
 -        location: Point
 +        level: i32,
 +        location: Point,
 +        tile_type: TileType
      ) -> Character {
          Character {
              name: name,
 @@ -113,6 +117,29 @@ impl Player for Character {              dodge: dodge,
              luck: luck,
              xp: 0,
 +            level: 0,
 +            location: location,
 +            tile_type: TileType::Player
 +        }
 +    }
 +
 +    fn place(&mut self, location: Point) {
 +        self.location = location;
 +    }
 +
 +    fn select(&self, player_name: String, player_luck: i32) -> Self {
 +        Self::new(
 +            player_name,
 +            self.class.to_string(),
 +            self.health,
 +            self.attack,
 +            self.dodge,
 +            self.luck + player_luck,
 +            0,
 +            (0,0)
 +        )
 +    }
 +
              location: location,
              tile_type: TileType::Player
          }
 diff --git a/src/main.rs b/src/main.rs index f7e7f0f..9f5e45b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,9 +46,10 @@ fn main() {      let mut dungeon = Dungeon::new(          window.get_max_x() as usize, -        window.get_max_y() as usize - 2, +        window.get_max_y() as usize - 2, // allow 2 lines for game stats          5      ); +      dungeon.generate();      let start_location = dungeon.levels[0].get_start_point(); @@ -60,9 +61,9 @@ fn main() {          10,          10,          20, +        0,          start_location      ); -    character.place(start_location);      render_level(&window, &dungeon.levels[0]); @@ -71,7 +72,20 @@ fn main() {      loop {          // update actors + +          // update character +        window.mv(window.get_max_y() - 2, 0); +        window.clrtoeol(); +         +        window.refresh(); + +        window.addstr(character.stats() + "\n"); +        window.addstr(character.info() + "\n"); + +        window.mv(character.location.1 as i32,character.location.0 as i32); +        window.refresh(); +        draw_block(&window, &world::TileType::Character);          window.refresh();          // get input and execute it @@ -86,6 +100,7 @@ fn main() {              Some(_) => (),              None => (),          } +        // actors actions (normally attack / interact if on same location as the character)      }      endwin();  } | 
