From 5c495b75f25c324b5e468d0aa80d0699bb5f3fd2 Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Wed, 25 Oct 2017 09:56:36 -0500 Subject: -moved drawing to the map and out of character -now will just compute free spaces at list level and pass to characters --- src/map.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/map.rs') 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, } -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() { -- cgit v1.2.3