Add electric static sound effect

This commit is contained in:
Alex Page 2022-01-25 17:56:18 -05:00
parent 0ee6fc1afe
commit 5284b33808

View file

@ -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;
} }