From 8693a266c2c9a8448b70d87d487ed211c439cbc4 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Wed, 19 Jun 2019 04:45:46 -0500 Subject: camera now doesnt display unused map --- src/tileset.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/tileset.rs') diff --git a/src/tileset.rs b/src/tileset.rs index d4e652f..17f4f61 100644 --- a/src/tileset.rs +++ b/src/tileset.rs @@ -1,30 +1,23 @@ use ggez::filesystem::File; use ggez::graphics::Rect; +use crate::constants; use crate::xmlelements::XMLElements; pub struct Tileset { pub tiles: Vec, - pub tile_width: f32, - pub tile_height: f32, } impl Tileset { pub fn new(file: File) -> Tileset { let elements = XMLElements::new(file); + let height = elements.get_element_attribute("image", "height").unwrap(); let columns = elements .get_element_attribute("tileset", "columns") .unwrap(); - let height = elements.get_element_attribute("image", "height").unwrap(); - let tile_width = elements - .get_element_attribute("tileset", "tilewidth") - .unwrap() as f32; - let tile_height = elements - .get_element_attribute("tileset", "tileheight") - .unwrap() as f32; - let rows = height / (tile_height as usize); + let rows = height / (constants::TILE_HEIGHT as usize); let mut tiles = Vec::new(); tiles.push(Rect::zero()); @@ -39,10 +32,6 @@ impl Tileset { } } - Tileset { - tiles, - tile_height, - tile_width, - } + Tileset { tiles } } } -- cgit v1.2.3