summaryrefslogtreecommitdiff
path: root/src/map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.rs')
-rw-r--r--src/map.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/map.rs b/src/map.rs
index 2505747..0617042 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -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() {