diff options
author | tom barrett <spalf0@gmail.com> | 2019-06-16 10:33:29 -0500 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2019-06-16 10:33:29 -0500 |
commit | 49b07a29ab42b2d550becfd0de8da4231341b706 (patch) | |
tree | 7b2b16d90e00d825e4d813021d6b2eb3966b4528 /src/main.rs | |
parent | 71db6116e43d2c1233cfbc4e8f6cdaa079a3667e (diff) |
layers now supported
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs index bb85c0a..953d326 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,8 @@ use ggez::graphics::{self, spritebatch::SpriteBatch, DrawParam, FilterMode, Imag use ggez::nalgebra::{Point2, Vector2}; use ggez::{Context, ContextBuilder, GameResult}; use pax_romana::constants; -use pax_romana::map::{Map, Tileset}; +use pax_romana::map::Map; +use pax_romana::tileset::Tileset; struct State { map: Map, @@ -34,17 +35,19 @@ impl EventHandler for State { fn draw(&mut self, context: &mut Context) -> GameResult { graphics::clear(context, graphics::BLACK); - for x in 0..self.map.width { - for y in 0..self.map.height { - let draw_param = DrawParam::default() - .src(self.tileset.tiles[self.map.data[x + (y * self.map.height)]]) - .dest(Point2::new( - self.tileset.tile_width * constants::TILE_SCALE * x as f32, - self.tileset.tile_height * constants::TILE_SCALE * y as f32, - )) - .scale(Vector2::new(constants::TILE_SCALE, constants::TILE_SCALE)); + for layer in self.map.layers.iter() { + for x in 0..self.map.width { + for y in 0..self.map.height { + let draw_param = DrawParam::default() + .src(self.tileset.tiles[layer.data[x + (y * self.map.height)]]) + .dest(Point2::new( + self.tileset.tile_width * constants::TILE_SCALE * x as f32, + self.tileset.tile_height * constants::TILE_SCALE * y as f32, + )) + .scale(Vector2::new(constants::TILE_SCALE, constants::TILE_SCALE)); - self.spritebatch.add(draw_param); + self.spritebatch.add(draw_param); + } } } |