Skip to content

Commit

Permalink
Check if two hit boxes do not overlap, not just the corners
Browse files Browse the repository at this point in the history
  • Loading branch information
aznhassan committed Jul 12, 2024
1 parent b369b77 commit 30cde21
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions libs/game/hitbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,8 @@ namespace game {
overlapsWith(other: Hitbox): boolean {
this.updateIfInvalid();
other.updateIfInvalid();
if (this.contains(other.left, other.top)) return true;
if (this.contains(other.left, other.bottom)) return true;
if (this.contains(other.right, other.top)) return true;
if (this.contains(other.right, other.bottom)) return true;
if (other.contains(this.left, this.top)) return true;
if (other.contains(this.left, this.bottom)) return true;
if (other.contains(this.right, this.top)) return true;
if (other.contains(this.right, this.bottom)) return true;
return false;
return !(this.left > other.right || this.right < other.left ||
this.top > other.bottom || this.bottom < other.top)
}
}

Expand Down

0 comments on commit 30cde21

Please sign in to comment.