feat: add pacman death sound

This commit is contained in:
Ryan Walters
2025-09-06 10:39:18 -05:00
parent 9c274de901
commit c8f389b163
5 changed files with 62 additions and 1 deletions

View File

@@ -26,6 +26,10 @@ pub struct AudioState {
pub enum AudioEvent {
/// Play the "eat" sound when Pac-Man consumes a pellet
PlayEat,
/// Play the death sound
PlayDeath,
/// Stop all currently playing sounds
StopAll,
}
/// Non-send resource wrapper for SDL2 audio system
@@ -59,6 +63,16 @@ pub fn audio_system(
// 4 eat sounds available
}
}
AudioEvent::PlayDeath => {
if !audio.0.is_disabled() && !audio_state.muted {
audio.0.death();
}
}
AudioEvent::StopAll => {
if !audio.0.is_disabled() {
audio.0.stop_all();
}
}
}
}
}