From cccfb66c7c58bf464252e942ef2b742b41ece19e Mon Sep 17 00:00:00 2001 From: tom barrett Date: Sat, 22 Jun 2019 10:11:18 -0500 Subject: now draw at the tile level --- src/state.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/state.rs') diff --git a/src/state.rs b/src/state.rs index b0a497c..20066a8 100644 --- a/src/state.rs +++ b/src/state.rs @@ -9,7 +9,7 @@ use crate::tileset::Tileset; pub struct State { map: Map, - tileset: Tileset, + //tileset: Tileset, spritebatch: SpriteBatch, camera: Camera, player: Player, @@ -20,12 +20,14 @@ impl State { let mut image = Image::new(context, "/tileset.png")?; image.set_filter(FilterMode::Nearest); - let map = Map::new(filesystem::open(context, "/map.tmx")?); + let tileset = Tileset::new(filesystem::open(context, "/tileset.tsx")?); + + let map = Map::new(filesystem::open(context, "/map.tmx")?, &tileset); let map_dimensions = map.get_dimensions(); Ok(State { map, - tileset: Tileset::new(filesystem::open(context, "/tileset.tsx")?), + // tileset, spritebatch: SpriteBatch::new(image), camera: Camera::new(context, map_dimensions), player: Player::new(map_dimensions), @@ -43,7 +45,7 @@ impl EventHandler for State { fn draw(&mut self, context: &mut Context) -> GameResult { graphics::clear(context, graphics::BLACK); - self.map.draw(&mut self.spritebatch, &self.tileset); + self.map.draw(&mut self.spritebatch); self.player.draw(&mut self.spritebatch); graphics::draw( -- cgit v1.2.3 From 15b4ade5a357a791cf3ffa86cfe78b5f7ae270c9 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Mon, 24 Jun 2019 09:31:24 -0500 Subject: now draws accurately depending on flip --- src/state.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/state.rs') diff --git a/src/state.rs b/src/state.rs index 20066a8..b06d535 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,5 +1,5 @@ use ggez::event::{EventHandler, KeyCode, KeyMods}; -use ggez::graphics::{self, spritebatch::SpriteBatch, DrawParam, FilterMode, Image}; +use ggez::graphics::{self, spritebatch::SpriteBatch, DrawParam, FilterMode, Image, WrapMode}; use ggez::{filesystem, Context, GameResult}; use crate::camera::Camera; @@ -9,7 +9,6 @@ use crate::tileset::Tileset; pub struct State { map: Map, - //tileset: Tileset, spritebatch: SpriteBatch, camera: Camera, player: Player, @@ -19,6 +18,7 @@ impl State { pub fn new(context: &mut Context) -> GameResult { let mut image = Image::new(context, "/tileset.png")?; image.set_filter(FilterMode::Nearest); + image.set_wrap(WrapMode::Mirror, WrapMode::Mirror); let tileset = Tileset::new(filesystem::open(context, "/tileset.tsx")?); @@ -27,7 +27,6 @@ impl State { Ok(State { map, - // tileset, spritebatch: SpriteBatch::new(image), camera: Camera::new(context, map_dimensions), player: Player::new(map_dimensions), -- cgit v1.2.3 From ee8d055be8326eb1561900bcca6acd9e38071f4a Mon Sep 17 00:00:00 2001 From: tom barrett Date: Thu, 27 Jun 2019 03:31:33 -0500 Subject: tiles can now animate --- src/state.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/state.rs') diff --git a/src/state.rs b/src/state.rs index b06d535..a981924 100644 --- a/src/state.rs +++ b/src/state.rs @@ -36,6 +36,7 @@ impl State { impl EventHandler for State { fn update(&mut self, context: &mut Context) -> GameResult { + self.map.update(); self.player.update(context); self.camera.give_center(self.player.position); Ok(()) -- cgit v1.2.3