diff options
author | Tom Barrett <tombarrett@siu.edu> | 2017-10-25 09:56:36 -0500 |
---|---|---|
committer | Tom Barrett <tombarrett@siu.edu> | 2017-10-25 09:56:36 -0500 |
commit | 5c495b75f25c324b5e468d0aa80d0699bb5f3fd2 (patch) | |
tree | 0572763449f700fc407d17f185a2ce1c1495114f /src/map.rs | |
parent | 5b7a80d0e1fc0fcddbfad976a3f0fbbf7f6cd2ab (diff) |
-moved drawing to the map and out of character
-now will just compute free spaces at list level and pass to characters
Diffstat (limited to 'src/map.rs')
-rw-r--r-- | src/map.rs | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -5,6 +5,7 @@ use std::io::prelude::*; extern crate pancurses; use pancurses::{newwin, ColorPair}; +use character::Character; use location::Location; pub struct Map{ @@ -15,8 +16,8 @@ pub struct Map{ pub impassable :Vec<Location>, } -impl Map{ - pub fn new() -> Map{ +impl Map { + pub fn new() -> Map { let file = File::open("data/map.txt").expect("Cant open map file !"); let reader = BufReader::new(file); @@ -48,7 +49,7 @@ impl Map{ impassable.push(Location{x : x as i32, y : height-1 as i32}); } - Map{ + Map { height : height, width : width, window: newwin(height, width, 0, 0), @@ -57,6 +58,11 @@ impl Map{ } } + pub fn draw(&self, character : &Character) { + self.window.attron(ColorPair(character.color)); + self.window.mvaddch(character.location.x, character.location.y, character.symbol); + } + pub fn fill(&mut self) { for (i, row) in self.map_data.iter().enumerate() { for (j, index) in row.chars().enumerate() { |