Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: play sound on player death #1046

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading