Skip to content

Commit

Permalink
chore(sounds): play whoosh on lose
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 23, 2025
1 parent 1cb4cac commit c181b53
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
Binary file added public/sounds/whoosh.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions src/constants/sounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum Sound {
Explode = 'Explode',
Hit = 'Hit',
Shoot = 'Shoot',
Whoosh = 'Whoosh',
}
5 changes: 4 additions & 1 deletion src/gameobjects/player.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Scene, Sprite, Tag } from '../constants'
import { Scene, Sound, Sprite, Tag } from '../constants'
import { addAttack, addCursorKeys } from '../events'
import { stopMusic } from '../gameobjects'

Expand All @@ -24,8 +24,11 @@ export function addPlayer(x = center().x, y = center().y) {
})

player.onHurt(() => {
play(Sound.Hit)

if (player.hp() <= 0) {
stopMusic()
play(Sound.Whoosh)
go(Scene.Lose)
}
})
Expand Down
1 change: 1 addition & 0 deletions src/scenes/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ scene(Scene.Preload, () => {
[Sound.Explode, 'sounds/explode.mp3'],
[Sound.Hit, 'sounds/hit.mp3'],
[Sound.Shoot, 'sounds/shoot.mp3'],
[Sound.Whoosh, 'sounds/whoosh.mp3'],
]

sounds.forEach(([name, src]) => {
Expand Down

0 comments on commit c181b53

Please sign in to comment.