fix block dist detection

This commit is contained in:
Evan Pratten 2021-10-04 01:00:31 -04:00
parent eebfe8ec94
commit a7265e0994

View File

@ -45,13 +45,14 @@ impl WorldSpaceRender for InGameScreen {
.appear .appear
.iter() .iter()
.map(|zone| { .map(|zone| {
// Vector2::new( let left_edge_dist = (zone.x + WORLD_LEVEL_X_OFFSET) - self.player.position.x;
// zone.x + WORLD_LEVEL_X_OFFSET + (zone.width / 2.0), let right_edge_dist =
// zone.y - cur_level.platform_tex.height as f32, (zone.x + zone.width + WORLD_LEVEL_X_OFFSET) - self.player.position.x;
// ) if left_edge_dist < 0.0 && right_edge_dist > 0.0 {
// .distance_to(self.player.position) as i32 0
((zone.x + WORLD_LEVEL_X_OFFSET + (zone.width / 2.0)) - self.player.position.x) } else {
.abs() as i32 left_edge_dist.abs().min(right_edge_dist.abs()) as i32
}
}) })
.min() .min()
.unwrap_or(i32::MAX); .unwrap_or(i32::MAX);
@ -88,13 +89,14 @@ impl WorldSpaceRender for InGameScreen {
.disappear .disappear
.iter() .iter()
.map(|zone| { .map(|zone| {
// Vector2::new( let left_edge_dist = (zone.x + WORLD_LEVEL_X_OFFSET) - self.player.position.x;
// zone.x + WORLD_LEVEL_X_OFFSET + (zone.width / 2.0), let right_edge_dist =
// zone.y - cur_level.platform_tex.height as f32, (zone.x + zone.width + WORLD_LEVEL_X_OFFSET) - self.player.position.x;
// ) if left_edge_dist < 0.0 && right_edge_dist > 0.0 {
// .distance_to(self.player.position) as i32 0
((zone.x + WORLD_LEVEL_X_OFFSET + (zone.width / 2.0)) - self.player.position.x) } else {
.abs() as i32 left_edge_dist.abs().min(right_edge_dist.abs()) as i32
}
}) })
.min() .min()
.unwrap_or(i32::MAX); .unwrap_or(i32::MAX);