Skip to content

Commit

Permalink
fixing some issues with rolling pillars
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Aug 14, 2023
1 parent d427f0d commit b83abc6
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions base/interactable_objects/RollingPillar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export class RollablePillar extends InteractableObjects {
if (
io !== this &&
io.active &&
io.body &&
!io.allow_jumping_over_it &&
!io.allow_jumping_through_it &&
io.shapes_collision_active &&
Expand Down Expand Up @@ -207,7 +208,10 @@ export class RollablePillar extends InteractableObjects {
if (char.trying_to_push_direction === directions.left && point.x >= this.tile_pos.x) {
continue;
}
const distance = get_sqr_distance(point.x, this.tile_x_pos, point.y, this.tile_y_pos);
const distance =
this._pillar_direction === pillar_directions.VERTICAL
? Math.abs(point.x - this.tile_x_pos)
: Math.abs(point.y - this.tile_y_pos);
if (distance < last_distance) {
next_contact = Object.assign({}, point);
last_distance = distance;
Expand All @@ -229,15 +233,23 @@ export class RollablePillar extends InteractableObjects {
}
let rolling_pillar_will_fall = false;
if (this._falling_pos) {
const distance = get_sqr_distance(
this._falling_pos.x,
this.tile_x_pos,
this._falling_pos.y,
this.tile_y_pos
);
if (distance < last_distance) {
next_contact = this._falling_pos;
rolling_pillar_will_fall = true;
if (
!(
(char.trying_to_push_direction === directions.down && this._falling_pos.y <= this.tile_pos.y) ||
(char.trying_to_push_direction === directions.up && this._falling_pos.y >= this.tile_pos.y) ||
(char.trying_to_push_direction === directions.right &&
this._falling_pos.x <= this.tile_pos.x) ||
(char.trying_to_push_direction === directions.left && this._falling_pos.x >= this.tile_pos.x)
)
) {
const distance =
this._pillar_direction === pillar_directions.VERTICAL
? Math.abs(this._falling_pos.x - this.tile_x_pos)
: Math.abs(this._falling_pos.y - this.tile_y_pos);
if (distance < last_distance) {
next_contact = this._falling_pos;
rolling_pillar_will_fall = true;
}
}
}

Expand Down

0 comments on commit b83abc6

Please sign in to comment.