Add electric static sound effect
This commit is contained in:
parent
0ee6fc1afe
commit
5284b33808
1 changed files with 19 additions and 2 deletions
21
src/main.rs
21
src/main.rs
|
@ -77,8 +77,25 @@ fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World, sound_system: &m
|
||||||
|| destination_y < 0
|
|| destination_y < 0
|
||||||
|| (destination_y as usize) >= MAP_HEIGHT
|
|| (destination_y as usize) >= MAP_HEIGHT
|
||||||
{
|
{
|
||||||
let blocked_sound = sound_effects.blocked_sound.clone();
|
let mut rng = RandomNumberGenerator::new();
|
||||||
sound_system.play_sound(blocked_sound);
|
let static_sound = sound_system.render_sound_effect(&SoundEffect {
|
||||||
|
sounds: (1..=33)
|
||||||
|
.map(|_| {
|
||||||
|
if rng.roll_dice(1, 2) > 1 {
|
||||||
|
Sound {
|
||||||
|
sound_type: SoundType::Noise(3000, 7000),
|
||||||
|
duration: Duration::from_millis(rng.range(1, 15)),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Sound {
|
||||||
|
sound_type: SoundType::Silence,
|
||||||
|
duration: Duration::from_millis(rng.range(0, 30)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
});
|
||||||
|
sound_system.play_sound(static_sound);
|
||||||
player.last_moved = now;
|
player.last_moved = now;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue