diff options
Diffstat (limited to 'src/map.rs')
-rw-r--r-- | src/map.rs | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -4,6 +4,7 @@ use ggez::nalgebra::Point2; use xml::reader::XmlEvent::Characters; use crate::constants; +use crate::entity::Operable; use crate::layer::Layer; use crate::tileset::Tileset; use crate::xmlelements::XMLElements; @@ -16,6 +17,20 @@ pub struct Map { spawns: Vec<(String, Point2<f32>)>, } +impl Operable for Map { + fn draw(&self, spritebatch: &mut SpriteBatch) { + for layer in self.layers.iter() { + layer.draw(spritebatch); + } + } + + fn update(&mut self) { + for layer in self.layers.iter_mut() { + layer.update(); + } + } +} + impl Map { pub fn new(file: File, tileset: &Tileset) -> Map { let elements = XMLElements::new(file); @@ -72,18 +87,6 @@ impl Map { spawn_points } - pub fn draw(&self, spritebatch: &mut SpriteBatch) { - for layer in self.layers.iter() { - layer.draw(spritebatch); - } - } - - pub fn update(&mut self) { - for layer in self.layers.iter_mut() { - layer.update(); - } - } - pub fn get_spawns(&self) -> Vec<(String, Point2<f32>)> { self.spawns.clone() } |