Compare commits

..

2 commits

Author SHA1 Message Date
3674e4c26a Improve wall destruction sound
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
2022-11-27 23:53:27 -05:00
a7759cfa06 Fix wasm target 2022-11-27 23:53:03 -05:00
3 changed files with 12 additions and 7 deletions

3
Cargo.lock generated
View file

@ -827,8 +827,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"js-sys",
"libc", "libc",
"wasi", "wasi",
"wasm-bindgen",
] ]
[[package]] [[package]]
@ -1067,6 +1069,7 @@ dependencies = [
"bracket-lib", "bracket-lib",
"console_error_panic_hook", "console_error_panic_hook",
"cpal", "cpal",
"getrandom",
"hecs", "hecs",
"instant", "instant",
"oddio", "oddio",

View file

@ -24,6 +24,7 @@ console_error_panic_hook = "0.1.7"
wasm-bindgen = "0.2.79" wasm-bindgen = "0.2.79"
instant = "0.1.12" instant = "0.1.12"
rand = "0.8.5" rand = "0.8.5"
getrandom = { version = "0.2.4", features = ["js"] }
[target.'cfg(windows)'.build-dependencies] [target.'cfg(windows)'.build-dependencies]
winres = "0.1.12" winres = "0.1.12"

View file

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