Skip to content

Commit

Permalink
Add hitbox overlaps flag (#1454)
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll committed Jul 28, 2023
1 parent 373df44 commit 47c24cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/game/sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,8 @@ class Sprite extends sprites.BaseSprite {
return false
if (other.flags & SPRITE_NO_SPRITE_OVERLAPS)
return false
if (this.flags & sprites.Flag.HitboxOverlaps || other.flags & sprites.Flag.HitboxOverlaps)
return other._hitbox.overlapsWith(this._hitbox);
if (!other._hitbox.overlapsWith(this._hitbox))
return false;
if (!this.isScaled() && !other.isScaled()) {
Expand Down
1 change: 1 addition & 0 deletions libs/game/sprites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ namespace sprites {
GhostThroughTiles = 1 << 10, // No overlaps with tiles
GhostThroughWalls = 1 << 11, // No collisions with walls
GhostThroughSprites = 1 << 12, // No overlaps with other sprites
HitboxOverlaps = 1 << 13, // If set, overlaps with this sprite are based off of both sprites' hitboxes and not pixel perfect
Ghost = sprites.Flag.GhostThroughSprites | sprites.Flag.GhostThroughWalls | sprites.Flag.GhostThroughTiles, // doesn't collide with other sprites or walls
}
}

0 comments on commit 47c24cc

Please sign in to comment.