.
This commit is contained in:
@@ -22,19 +22,19 @@ impl<'a> Collision<'a> {
|
||||
|
||||
pub fn gen_bvt(mut self, entity_state: &'a EntState<'a>) {
|
||||
|
||||
let mut dynamic_sprites: Box<Vec<(&'a Sprite<'a>, AABB<f64>)>> = 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<f64>)>= (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<f64>)> = Vec::new();
|
||||
// {
|
||||
|
||||
17
src/main.rs
17
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();
|
||||
|
||||
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"));
|
||||
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user