Skip to content

Commit

Permalink
chore(gameobjects): allow bubbles to combine and get bigger and pop
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 25, 2025
1 parent 7085c2e commit cd55482
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/gameobjects/bubble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function addBubble(player: Player) {

if (hasBubble(currentEnemy)) {
const childBubble = currentEnemy.get(Tag.Bubbled)[0] as Bubble
childBubble.scaleTo(childBubble.scale.x * 1.1)
childBubble.scaleBy(1.1)
} else {
currentEnemy.add([
sprite(Sprite.BubbleGood),
Expand All @@ -37,6 +37,24 @@ export function addBubble(player: Player) {
}
})

bubble.onCollide(Tag.Bubble, (otherBubble) => {
let currentBubble: Bubble

if (bubble.scale.x >= (otherBubble as Bubble).scale.x) {
currentBubble = bubble
otherBubble.destroy()
} else {
currentBubble = otherBubble as Bubble
bubble.destroy()
}

if (currentBubble.scale.x > 0.2) {
currentBubble.destroy()
} else {
currentBubble.scaleBy(1.1)
}
})

bubble.onCollide(Tag.Projectile, () => {
play(Sound.Hit)
bubble.destroy()
Expand Down

0 comments on commit cd55482

Please sign in to comment.