diff options
author | tom barrett <spalf0@gmail.com> | 2019-07-05 02:50:38 -0500 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2019-07-05 02:50:38 -0500 |
commit | 6589e5e3df63d5abf85313c4d21097432257f453 (patch) | |
tree | d53635ead10c9fa9dc951045eff9e31977457f8c /src/map.rs | |
parent | 83ff2ad49e6d3bf83fd85fcfee68a454372bf22a (diff) |
removed math, operable to map and layers, on the way to merging tile and frame
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() } |