summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs25
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);
+ }
}
}