diff options
author | tom barrett <spalf0@gmail.com> | 2019-07-02 04:23:33 -0500 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2019-07-02 04:23:33 -0500 |
commit | 6bf9e96140c91340d6ae643b6e0896aa734d8605 (patch) | |
tree | ea5fba741326bd952b7808d402c4bbaf572d170d /src/state.rs | |
parent | 1b5f06e902b9e5c5b0d5897fc981eeaa6dc39b37 (diff) |
entities now spawn on points
Diffstat (limited to 'src/state.rs')
-rw-r--r-- | src/state.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/state.rs b/src/state.rs index 077917b..1eb5e17 100644 --- a/src/state.rs +++ b/src/state.rs @@ -3,6 +3,7 @@ use ggez::graphics::{self, spritebatch::SpriteBatch, DrawParam, FilterMode, Imag use ggez::{filesystem, Context, GameResult}; use crate::camera::Camera; +use crate::entity::Entity; use crate::map::Map; use crate::player::Player; use crate::tileset::Tileset; @@ -12,6 +13,7 @@ pub struct State { spritebatch: SpriteBatch, camera: Camera, player: Player, + entities: Vec<Entity>, } impl State { @@ -26,10 +28,11 @@ impl State { let map_dimensions = map.get_dimensions(); Ok(State { - map, + map: map.clone(), spritebatch: SpriteBatch::new(image), camera: Camera::new(context, map_dimensions), player: Player::new(&tileset, map_dimensions), + entities: Entity::build_entities(&tileset, &map), }) } } @@ -48,6 +51,10 @@ impl EventHandler for State { self.map.draw(&mut self.spritebatch); self.player.draw(&mut self.spritebatch); + for entity in &self.entities { + entity.draw(&mut self.spritebatch); + } + graphics::draw( context, &self.spritebatch, |