Merge pull request #65 from Ewpratten/appear_fix

fix block dist detection
This commit is contained in:
Evan Pratten 2021-10-03 22:01:14 -07:00 committed by GitHub
commit c6fa61cc12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);