Skip to content

Commit

Permalink
feat: play sound on player death (#1046)
Browse files Browse the repository at this point in the history
Added a glug sound when player dies to give additional audio feedback.
Here is the audio used:
https://freesound.org/people/brittmosel/sounds/529300/

This resolves #986.
  • Loading branch information
elliay authored Dec 5, 2024
1 parent 5d92c7d commit 1ec5db6
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions assets/player/skins/fishy/fishy.player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ sounds:
grab_volume: 0.05
drop: ../../sounds/drop.ogg
drop_volume: 0.05
death: ../../sounds/death.ogg
death_volume: 0.3

stats:
air_speed: 360
Expand Down
2 changes: 2 additions & 0 deletions assets/player/skins/orcy/orcy.player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ sounds:
grab_volume: 0.05
drop: ../../sounds/drop.ogg
drop_volume: 0.05
death: ../../sounds/death.ogg
death_volume: 0.3

stats:
air_speed: 360
Expand Down
2 changes: 2 additions & 0 deletions assets/player/skins/pescy/pescy.player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ sounds:
grab_volume: 0.05
drop: ../../sounds/drop.ogg
drop_volume: 0.05
death: ../../sounds/death.ogg
death_volume: 0.3

stats:
air_speed: 360
Expand Down
2 changes: 2 additions & 0 deletions assets/player/skins/sharky/sharky.player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ sounds:
grab_volume: 0.05
drop: ../../sounds/drop.ogg
drop_volume: 0.05
death: ../../sounds/death.ogg
death_volume: 0.3

stats:
air_speed: 360
Expand Down
Binary file added assets/player/sounds/death.ogg
Binary file not shown.
3 changes: 3 additions & 0 deletions src/core/metadata/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ pub struct PlayerSoundsMeta {

pub drop_volume: f64,
pub drop: Handle<AudioSource>,

pub death_volume: f64,
pub death: Handle<AudioSource>,
}

fn deserialize_arc<'de, T: Deserialize<'de>, D: Deserializer<'de>>(
Expand Down
3 changes: 3 additions & 0 deletions src/core/player/state/states/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub fn handle_player_state(
mut animations: CompMut<AnimationBankSprite>,
game_meta: Root<GameMeta>,
mut collision_world: CollisionWorld,
mut audio_center: ResMut<AudioCenter>,
) {
for (player_ent, (state, animation, _killed_player, player_idx)) in entities.iter_with((
&player_states,
Expand Down Expand Up @@ -79,6 +80,8 @@ pub fn handle_player_state(
let player_meta = &*assets.get(player_meta_handle);
ragdoll::use_ragdoll_collider(player_ent, player_meta, &mut collision_world);

audio_center.play_sound(player_meta.sounds.death, player_meta.sounds.death_volume);

// animation.current = match killed_player.hit_from {
// Some(hit_from)
// if {
Expand Down

0 comments on commit 1ec5db6

Please sign in to comment.