fishfolk / jumpy

Tactical 2D shooter in fishy pixels style. Made with Rust-lang 🦀 and Bevy 🪶
https://fishfolk.org/games/jumpy/
Other
1.6k stars 115 forks source link

feat: add audio settings #909

Closed nelson137 closed 6 months ago

nelson137 commented 6 months ago

Add an "Audio" page to settings with volume controls. It features a main volume slider and sliders to control music and sound effects separately.

This replaces AudioEvents with a new AudioCenter that manages all audios (I would've liked to use AudioManager but that's taken by bones).

before:

audio_events.play(*explosion_sound, *explosion_volume);

after:

audio_center.play_sound(*explosion_sound, *explosion_volume);

For sounds, the volume is calculated as main_volume * effects_volume * requested_volume where the requested volume is the argument to play_sound. A similar method exists for music.

Sound effects are modeled by entities with an Audio component. When they are stopped/finish the entity is killed. The music system only supported 1 song at a time, so music is stored on the AudioCenter as an Option<Audio>. This can easily be refactored to use entities, like sound effects do, in the future if needed.

nelson137 commented 6 months ago

I just upgraded shlex (v1.2.0) to v1.3.0 to fix the failing task due to the security advisory