Ensure hit beep on last frame of whip

This commit is contained in:
Alex Page 2022-01-31 18:15:04 -05:00
parent 9219b6c475
commit 770793ea68
2 changed files with 15 additions and 3 deletions

View file

@ -34,6 +34,7 @@ pub struct SoundEffects {
pub blocked: SoundSamples, pub blocked: SoundSamples,
pub whipping: SoundSamples, pub whipping: SoundSamples,
pub whipping_hit: SoundSamples, pub whipping_hit: SoundSamples,
pub whipping_hit_end: SoundSamples,
rng: RandomNumberGenerator, rng: RandomNumberGenerator,
} }
@ -125,6 +126,12 @@ impl SoundEffects {
}, },
], ],
}), }),
whipping_hit_end: ss.render_sound_effect(&SoundEffect {
sounds: vec![Sound {
sound_type: SoundType::Tone(400),
duration: Duration::from_millis(20),
}],
}),
rng: RandomNumberGenerator::new(), rng: RandomNumberGenerator::new(),
} }
} }

View file

@ -87,9 +87,14 @@ impl<'a> System<'a> for WhipSystem {
if let Some(sound) = &mut wants_to_whip.sound { if let Some(sound) = &mut wants_to_whip.sound {
sound.control::<oddio::Stop<_>, _>().stop(); sound.control::<oddio::Stop<_>, _>().stop();
} }
wants_to_whip.sound = Some( if wants_to_whip.frame == 7 {
sound_output.play_sound(sound_effects.whipping_hit.clone()), wants_to_whip.sound = None;
); sound_output.play_sound(sound_effects.whipping_hit_end.clone());
} else {
wants_to_whip.sound = Some(
sound_output.play_sound(sound_effects.whipping_hit.clone()),
);
}
} }
} }
} }