From 6bf9e96140c91340d6ae643b6e0896aa734d8605 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Tue, 2 Jul 2019 04:23:33 -0500 Subject: entities now spawn on points --- src/state.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/state.rs') 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, } 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, -- cgit v1.2.3