fix inability to jump on slopes in certain cases

This commit is contained in:
Alula 2021-06-28 13:06:38 +02:00
parent 79a6c93060
commit 47b42bcf1e
No known key found for this signature in database
GPG Key ID: 3E00485503A1D8BA
1 changed files with 12 additions and 6 deletions

View File

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