From 47c24ccc95330be6b8193cf2636a9dbee7015a80 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 28 Jul 2023 11:27:28 -0700 Subject: [PATCH] Add hitbox overlaps flag (#1454) --- libs/game/sprite.ts | 2 ++ libs/game/sprites.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/libs/game/sprite.ts b/libs/game/sprite.ts index e5e164571..01aec6ea4 100644 --- a/libs/game/sprite.ts +++ b/libs/game/sprite.ts @@ -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()) { diff --git a/libs/game/sprites.ts b/libs/game/sprites.ts index a04da28b7..17ebda7a0 100644 --- a/libs/game/sprites.ts +++ b/libs/game/sprites.ts @@ -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 } }