Skip to content

Commit 48aa160

Browse files
committed
add clock spawn noise
1 parent c4d4e66 commit 48aa160

File tree

6 files changed

+31
-1
lines changed

6 files changed

+31
-1
lines changed

assets/audio/sfx/new-clock-1.wav

240 KB
Binary file not shown.

assets/audio/sfx/new-clock-2.wav

266 KB
Binary file not shown.

assets/audio/sfx/new-clock-3.wav

193 KB
Binary file not shown.

assets/audio/sfx/new-clock-4.wav

144 KB
Binary file not shown.

src/game/assets.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ pub enum SfxKey {
290290
ClockDown2,
291291
ClockDown3,
292292
ClockDown4,
293+
ClockSpawn1,
294+
ClockSpawn2,
295+
ClockSpawn3,
296+
ClockSpawn4,
293297
}
294298

295299
impl AssetKey for SfxKey {
@@ -367,6 +371,22 @@ impl FromWorld for HandleMap<SfxKey> {
367371
SfxKey::ClockDown4,
368372
asset_server.load("audio/sfx/clock-down-4.wav"),
369373
),
374+
(
375+
SfxKey::ClockSpawn1,
376+
asset_server.load("audio/sfx/new-clock-1.wav"),
377+
),
378+
(
379+
SfxKey::ClockSpawn2,
380+
asset_server.load("audio/sfx/new-clock-2.wav"),
381+
),
382+
(
383+
SfxKey::ClockSpawn3,
384+
asset_server.load("audio/sfx/new-clock-3.wav"),
385+
),
386+
(
387+
SfxKey::ClockSpawn4,
388+
asset_server.load("audio/sfx/new-clock-4.wav"),
389+
),
370390
]
371391
.into()
372392
}

src/game/spawn/clock.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use bevy::{prelude::*, sprite::Anchor};
33
use crate::{
44
game::{
55
assets::{HandleMap, ImageKey, SfxKey},
6-
audio::sfx::{PlayLoopingSfx, StopLoopingSfx},
6+
audio::sfx::{PlayLoopingSfx, PlaySfx, StopLoopingSfx},
77
},
88
screen::Screen,
99
AppSet,
@@ -464,6 +464,16 @@ fn spawn_interact_clock(
464464
image_handles: Res<HandleMap<ImageKey>>,
465465
clocks: Query<(&Clock, &Transform), With<Interactable>>,
466466
) {
467+
let r = rand::random::<f32>();
468+
if r < 0.25 {
469+
commands.trigger(PlaySfx::Key(SfxKey::ClockSpawn1));
470+
} else if r < 0.5 {
471+
commands.trigger(PlaySfx::Key(SfxKey::ClockSpawn2));
472+
} else if r < 0.75 {
473+
commands.trigger(PlaySfx::Key(SfxKey::ClockSpawn3));
474+
} else {
475+
commands.trigger(PlaySfx::Key(SfxKey::ClockSpawn4));
476+
}
467477
let clock_count = clocks.iter().count();
468478
let translation = positions.clock_spawn;
469479
let clock_data = &clock_data.clocks[clock_count];

0 commit comments

Comments
 (0)