Skip to content

Commit

Permalink
chore(gameobjects): enclose enemy in bubble when bubble hits
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 25, 2025
1 parent 9baf507 commit f57c05b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/gameobjects/bubble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/gameobjects/enemy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit f57c05b

Please sign in to comment.