From f57c05b3dfbecb8bccdc6b49df4f62d043df6bfd Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 24 Jan 2025 20:11:33 -0500 Subject: [PATCH] chore(gameobjects): enclose enemy in bubble when bubble hits --- src/gameobjects/bubble.ts | 2 ++ src/gameobjects/enemy.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gameobjects/bubble.ts b/src/gameobjects/bubble.ts index 3e09a9e..73d06ee 100644 --- a/src/gameobjects/bubble.ts +++ b/src/gameobjects/bubble.ts @@ -22,6 +22,8 @@ export function addBubble(player: Player) { bubble.destroy() const currentEnemy = enemy as Enemy currentEnemy.hurt(DAMAGE) + currentEnemy.add([sprite(Sprite.BubbleGood), anchor('center'), scale(0.2)]) + currentEnemy.bubble = true }) return bubble diff --git a/src/gameobjects/enemy.ts b/src/gameobjects/enemy.ts index 2de36d3..84d0bfa 100644 --- a/src/gameobjects/enemy.ts +++ b/src/gameobjects/enemy.ts @@ -31,12 +31,16 @@ export function addEnemy(x: number, y: number) { scale(0.75), state(State.Move, Object.values(State)), Tag.Enemy, - { damage, speed }, + { bubble: false, damage, speed }, ]) addEnemyState(enemy) enemy.onCollide(Tag.Player, async () => { + if (enemy.bubble) { + return + } + enemy.enterState(State.Attack) getPlayer()?.hurt(enemy.damage) })