Improve wall destruction sound
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Alex Page 2022-11-27 23:53:27 -05:00
parent a7759cfa06
commit 3674e4c26a

View file

@ -1,4 +1,4 @@
use std::{iter, time::Duration};
use std::{cmp, iter, time::Duration};
use bracket_lib::random::RandomNumberGenerator;
@ -44,6 +44,7 @@ pub struct SoundEffects {
impl SoundEffects {
pub fn new(sound_output: &SoundOutput) -> Self {
let mut rng = RandomNumberGenerator::new();
Self {
startup: sound_output.render_sound_effect(&SoundEffect {
sounds: (1..800)
@ -57,7 +58,7 @@ impl SoundEffects {
sounds: vec![
Sound {
sound_type: SoundType::Noise(350, 900),
duration: Duration::from_millis(6),
duration: Duration::from_millis(5),
},
Sound {
sound_type: SoundType::Silence,
@ -133,12 +134,12 @@ impl SoundEffects {
}],
}),
whipping_hit_block: sound_output.render_sound_effect(&SoundEffect {
sounds: (20..=5700)
sounds: (20_i32..=5700_i32)
.rev()
.step_by(100)
.step_by(5)
.map(|x| Sound {
sound_type: SoundType::Noise(0, x),
duration: Duration::from_millis(18),
sound_type: SoundType::Tone(cmp::max(0, rng.range(0, x * 2) - x) as u32),
duration: Duration::from_micros(665),
})
.collect(),
}),
@ -190,7 +191,7 @@ impl SoundEffects {
})
.collect(),
}),
rng: RandomNumberGenerator::new(),
rng,
}
}