1
0
Fork 0

Compare commits

...

3 commits

Author SHA1 Message Date
53ac3840ba feat(gameover): only allow the user to switch state after the gameover sound has been played. 2025-09-26 12:10:54 +02:00
1b187d7412 fix(audio): implement IsPlaying() correctly
cant use rl.IsSoundPlaying() because we create sound aliases.
so we must look at the sm.active slice instead
2025-09-26 12:09:05 +02:00
cb6e66bc45 chore: add editorconfig 2025-09-25 21:57:52 +02:00
3 changed files with 16 additions and 5 deletions

7
.editorconfig Normal file
View file

@ -0,0 +1,7 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
[*.go]
indent_style = tab
indent_size = 4

View file

@ -55,7 +55,9 @@ func (sm *Manager) Stop(id SoundID) {
}
func (sm Manager) IsPlaying(id SoundID) bool {
return rl.IsSoundPlaying(*sm.library.Get(id))
return slices.ContainsFunc(sm.active, func(e audio) bool {
return e.id == id
})
}
// Pause all active sounds

View file

@ -19,12 +19,14 @@ func (GameOver) Exit() {
}
func (GameOver GameOver) Update(fsm state.Transitioner, delta float32) {
if !audio.IsPlaying(assets.SFX_GAME_OVER) {
if rl.IsKeyPressed(rl.KeyEnter) {
fsm.Switch("gameplay")
} else if rl.IsKeyPressed(rl.KeyQ) {
fsm.Switch("menu")
}
}
}
func (GameOver *GameOver) Render() {
render.Begin(rl.Black)