summaryrefslogtreecommitdiff
path: root/src/map.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/map.rs
parent0567e86e184684ace269edad903a740e6f2f4024 (diff)
camera now doesnt display unused map
Diffstat (limited to 'src/map.rs')
-rw-r--r--src/map.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/map.rs b/src/map.rs
index 21ebc5c..57b39f5 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -18,9 +18,7 @@ impl Map {
let elements = XMLElements::new(file);
let width = elements.get_element_attribute("map", "width").unwrap();
-
let height = elements.get_element_attribute("map", "height").unwrap();
-
let layers = elements
.events
.iter()
@@ -40,15 +38,15 @@ impl Map {
}
}
- pub fn draw(&mut self, spritebatch: &mut SpriteBatch, tileset: &Tileset) {
+ pub fn draw(&self, spritebatch: &mut SpriteBatch, tileset: &Tileset) {
for layer in self.layers.iter() {
for x in 0..self.width {
for y in 0..self.height {
let draw_param = DrawParam::default()
.src(tileset.tiles[layer.data[x + (y * self.height)]])
.dest(Point2::new(
- tileset.tile_width * constants::TILE_SCALE * x as f32,
- tileset.tile_height * constants::TILE_SCALE * y as f32,
+ constants::TILE_WIDTH * constants::TILE_SCALE * x as f32,
+ constants::TILE_HEIGHT * constants::TILE_SCALE * y as f32,
))
.scale(Vector2::new(constants::TILE_SCALE, constants::TILE_SCALE));
@@ -57,6 +55,13 @@ impl Map {
}
}
}
+
+ pub fn get_dimensions(&self) -> (f32, f32) {
+ (
+ (constants::TILE_WIDTH * constants::TILE_SCALE) * self.width as f32,
+ (constants::TILE_HEIGHT * constants::TILE_SCALE) * self.height as f32,
+ )
+ }
}
pub struct Layer {