From 6589e5e3df63d5abf85313c4d21097432257f453 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Fri, 5 Jul 2019 02:50:38 -0500 Subject: removed math, operable to map and layers, on the way to merging tile and frame --- src/map.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/map.rs') diff --git a/src/map.rs b/src/map.rs index fe51242..a3ddfb3 100644 --- a/src/map.rs +++ b/src/map.rs @@ -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)>, } +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)> { self.spawns.clone() } -- cgit v1.2.3