From 47b42bcf1eed3517e412b3388e6dd1bdb23a3b5c Mon Sep 17 00:00:00 2001 From: Alula <6276139+alula@users.noreply.github.com> Date: Mon, 28 Jun 2021 13:06:38 +0200 Subject: [PATCH] fix inability to jump on slopes in certain cases --- src/physics.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/physics.rs b/src/physics.rs index 96dd623..eaa2aa2 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -420,6 +420,8 @@ pub trait PhysicalEntity { let half_tile_size = tile_size / 2; let quarter_tile_size = half_tile_size / 2; + self.flags().set_hit_left_higher_half(true); + if self.x() < (x * 2 + 1) * half_tile_size && self.x() > (x * 2 - 1) * half_tile_size && (self.y() + self.hit_bounds().bottom as i32) @@ -440,7 +442,6 @@ pub trait PhysicalEntity { self.set_vel_y(0); } - self.flags().set_hit_left_higher_half(true); self.flags().set_hit_left_slope(true); self.flags().set_hit_bottom_wall(true); } @@ -452,6 +453,8 @@ pub trait PhysicalEntity { let half_tile_size = tile_size / 2; let quarter_tile_size = half_tile_size / 2; + self.flags().set_hit_left_lower_half(true); + if (self.x() < (x * 2 + 1) * half_tile_size) && (self.x() > (x * 2 - 1) * half_tile_size) && (self.y() + self.hit_bounds().bottom as i32) @@ -471,7 +474,6 @@ pub trait PhysicalEntity { self.set_vel_y(0); } - self.flags().set_hit_left_lower_half(true); self.flags().set_hit_left_slope(true); self.flags().set_hit_bottom_wall(true); } @@ -483,6 +485,8 @@ pub trait PhysicalEntity { let half_tile_size = tile_size / 2; let quarter_tile_size = half_tile_size / 2; + self.flags().set_hit_right_lower_half(true); + if (self.x() < (x * 2 + 1) * half_tile_size) && (self.x() > (x * 2 - 1) * half_tile_size) && (self.y() + self.hit_bounds().bottom as i32) @@ -502,7 +506,6 @@ pub trait PhysicalEntity { self.set_vel_y(0); } - self.flags().set_hit_right_lower_half(true); self.flags().set_hit_right_slope(true); self.flags().set_hit_bottom_wall(true); } @@ -514,6 +517,8 @@ pub trait PhysicalEntity { let half_tile_size = tile_size / 2; let quarter_tile_size = half_tile_size / 2; + self.flags().set_hit_right_higher_half(true); + if (self.x() < (x * 2 + 1) * half_tile_size) && (self.x() > (x * 2 - 1) * half_tile_size) && (self.y() + self.hit_bounds().bottom as i32) @@ -535,7 +540,6 @@ pub trait PhysicalEntity { self.set_vel_y(0); } - self.flags().set_hit_right_higher_half(true); self.flags().set_hit_right_slope(true); self.flags().set_hit_bottom_wall(true); } @@ -623,6 +627,8 @@ pub trait PhysicalEntity { let half_tile_size = tile_size / 2; let quarter_tile_size = half_tile_size / 2; + self.flags().set_hit_left_higher_half(true); + if self.x() < (x * 2 + 1) * half_tile_size && self.x() > (x * 2 - 1) * half_tile_size && (self.y() + self.hit_bounds().bottom as i32) > (y * tile_size) + (self.x() - x * tile_size) - quarter_tile_size @@ -638,7 +644,6 @@ pub trait PhysicalEntity { self.set_vel_y(0); } - self.flags().set_hit_left_higher_half(true); self.flags().set_hit_left_slope(true); self.flags().set_hit_bottom_wall(true); } @@ -650,6 +655,8 @@ pub trait PhysicalEntity { let half_tile_size = tile_size / 2; let quarter_tile_size = half_tile_size / 2; + self.flags().set_hit_right_higher_half(true); + if (self.x() < (x * 2 + 1) * half_tile_size) && (self.x() > (x * 2 - 1) * half_tile_size) && (self.y() + self.hit_bounds().bottom as i32) > (y * tile_size) - (self.x() - x * tile_size) - quarter_tile_size @@ -665,7 +672,6 @@ pub trait PhysicalEntity { self.set_vel_y(0); } - self.flags().set_hit_right_higher_half(true); self.flags().set_hit_right_slope(true); self.flags().set_hit_bottom_wall(true); }