diff --git a/src/collision.rs b/src/collision.rs index b034a6ed..97e1ca0a 100644 --- a/src/collision.rs +++ b/src/collision.rs @@ -22,19 +22,19 @@ impl<'a> Collision<'a> { pub fn gen_bvt(mut self, entity_state: &'a EntState<'a>) { - let mut dynamic_sprites: Box, AABB)>> = Box::new(Vec::new()); - { - let vec = entity_state.dynamic_entities.borrow(); - for i in vec.iter() { - let bounds = i.global_bounds(); - let pos = i.position(); - let volume = bounding_volume::AABB::new(na::Point2::new(pos.x as f64, pos.y as f64), - na::Point2::new((pos.x + bounds.width) as f64, (pos.y + bounds.width) as f64)); - - dynamic_sprites.push((i, volume)); - } - } - self.dynamic_bvh = Some(BVT::new_balanced(dynamic_sprites)); +// let mut dynamic_sprites: Vec<(&'a Sprite<'a>, AABB)>= (Vec::new()); +// { +// let vec = entity_state.dynamic_entities.borrow(); +// for i in vec.iter() { +// let bounds = i.global_bounds(); +// let pos = i.position(); +// let volume = bounding_volume::AABB::new(na::Point2::new(pos.x as f64, pos.y as f64), +// na::Point2::new((pos.x + bounds.width) as f64, (pos.y + bounds.width) as f64)); +// +// dynamic_sprites.push((i, volume)); +// } +// } +// self.dynamic_bvh = Some(BVT::new_balanced(dynamic_sprites)); // let mut static_sprites: Vec<(&Sprite, AABB)> = Vec::new(); // { diff --git a/src/main.rs b/src/main.rs index 851fa683..52607d7f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,11 +33,26 @@ use sfml::system::Vector2 as sfVec2; fn main() { + + // Resources + // Holds textures and their descriptions + + // Collision + // Holds the BVT which has a reference or owns the Sprite + + // EntState + // Holds the entities and the player + + // Entities (Sprites) have a texture so Resources must live longer + // Collision has references to sprites so EntState must live longer + + // Resources { EntState { Collision } } } + let mut resources = Resources::new(); let mut collision = Collision::new(); - let mut state = EntState::new(); + let mut state = EntState::new(); - state.read_static_entities(String::from("static_entities.txt"), &resources); + // state.read_static_entities(String::from("static_entities.txt"), &resources); //state.read_static_entities(String::from("static_entities.txt"), &resources); //state.read_dynamic_entities(String::from("dynamic_entities.txt")); diff --git a/src/resources.rs b/src/resources.rs index 3b86abcc..c5d92cf1 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -12,7 +12,8 @@ impl Resources { Resources { spritesheet_desc: util::read_spritesheet(String::from("spritesheet_complete.xml")), - spritesheet_text: Texture::from_file("spritesheet_complete.png").expect("Couldn't load texture") + spritesheet_text: Texture::from_file("spritesheet_complete.png") + .expect("Couldn't load texture") } } } \ No newline at end of file