Skip to content

Commit

Permalink
feat(gameobjects): destroy good bubble and bad bubble on collision
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 26, 2025
1 parent a55765c commit 5d4b6c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
6 changes: 6 additions & 0 deletions src/gameobjects/badbubble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,11 @@ export function addBadBubble(enemy: Enemy) {
badBubble.destroy()
})

badBubble.onCollide(Tag.Bubble, (bubble) => {
play(Sound.Pop, { detune: rand(-100, 100) })
badBubble.destroy()
bubble.destroy()
})

return badBubble
}
21 changes: 3 additions & 18 deletions src/gameobjects/enemy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,6 @@ import { multiplier, outsideCoordinates } from '../helpers'
import { getChildBubble, getPlayer } from '.'
import { incrementScore } from './score'

enum Damage {
Min = 1,
Max = 10,
}

enum Health {
Min = 20,
Max = 100,
}

enum Speed {
Min = 100,
Max = 300,
}

export function addEnemy() {
const sprites = [
Sprite.Bubbie,
Expand All @@ -28,9 +13,9 @@ export function addEnemy() {
Sprite.Pokey,
]

const speed = rand(Speed.Min, Speed.Max) * multiplier.value
const damage = rand(Damage.Min, Damage.Max) * multiplier.value
const hp = randi(Health.Min, Health.Max) * multiplier.value
const speed = randi(100, 300) * multiplier.value
const damage = randi(1, 10) * multiplier.value
const hp = randi(20, 100) * multiplier.value

const enemy = add([
sprite(sprites[randi(sprites.length)]),
Expand Down

0 comments on commit 5d4b6c7

Please sign in to comment.