summaryrefslogtreecommitdiff
path: root/src/tileset.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-06-19 04:45:46 -0500
committertom barrett <spalf0@gmail.com>2019-06-19 04:45:46 -0500
commit8693a266c2c9a8448b70d87d487ed211c439cbc4 (patch)
tree3330eeba26d6f5f65b7625c49215e54cd5394271 /src/tileset.rs
parent0567e86e184684ace269edad903a740e6f2f4024 (diff)
camera now doesnt display unused map
Diffstat (limited to 'src/tileset.rs')
-rw-r--r--src/tileset.rs19
1 files changed, 4 insertions, 15 deletions
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<Rect>,
- 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 }
}
}