From d1d8ad22d3ea3b8b40b4c553987817057ee22284 Mon Sep 17 00:00:00 2001 From: PraxTube Date: Mon, 5 Feb 2024 18:34:42 +0100 Subject: [PATCH] feat: Add striking sound with random pitch shift Closes #1 --- CREDITS.md | 8 ++++++++ assets/sounds/strike_sound.ogg | Bin 0 -> 9710 bytes src/assets.rs | 4 ++++ src/audio/mod.rs | 1 - src/player/strike.rs | 23 +++++++++++++++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 assets/sounds/strike_sound.ogg diff --git a/CREDITS.md b/CREDITS.md index 158d03f..40818fa 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -54,6 +54,14 @@ https://grappe.itch.io/medal ### Sounds +#### Swing + +- https://freesound.org/people/Eponn/sounds/547040/ +- https://freesound.org/people/spycrah/sounds/471097/ +- https://freesound.org/people/Artninja/sounds/700220/ + +Mixed by @TheYahton (https://github.com/PraxTube/insta-kill/issues/1) + ### Music https://shononoki.itch.io/bullet-hell-music-pack diff --git a/assets/sounds/strike_sound.ogg b/assets/sounds/strike_sound.ogg new file mode 100644 index 0000000000000000000000000000000000000000..64a8087f634282c0757a80c3c042de07c1d905b4 GIT binary patch literal 9710 zcmeHtcU;rSw)iAK2-N@qX=3OQKnVl{L=C+Qgx*{dYA8y#qM-_*NEZPygd&8pfPh^= z2%r=x5b9ff94*U}Vt2 zICTzZ4D<;)7;q>sC}xj6DIq}5U)LS8(Ok^sS4J`GLeG~^8VbV;Z= zEgLf^f3YHlA6rjP=GPg-q}c1ct|{Da^t!$}*JxR-W6V@Qt7F2}9yjG4&~g*ucOrJw zaH--)!?&>xXyx3d2&q7nDU!oJL%psv24c0jEDWGR%LG>WXqz_lP@C+?xRT?0O=mH^ zaa{`+R|hw!#QS+91WhNzPbVaLm8SVzN%Xps<};J#_c@Iunf{~xmiXi|r*14A0|RtL z!;0n+6_wCq5%k_Ay|AV!mSL&JjrvMGV6$%?^S#o`BIjiG84 zXMVTHe&nP5mOqWaF*^VRoGdF^_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Z72*u()7-K(L0{Dk#jN1@U#KJ2mF> zzn)XJLncS%r$7hJExj9lQoB~c+eo3y9zAREfbQ^Vyo-HIHPTI4H+DDlhUzrwTDxpC zve+1TJ7{(BU2*wR`ReWA&!4ydR2I1V@uQgAdu}h=z571t<$j?%d+ zC9+AYSgU+xfKKP`zr_74ME}5aCQlQ5uEaw?rn?K)%MU-wW9q*1(=}6|`K&l6xdAra zNm9;gW_G!8Z9G|UgMI&avf%u=?U%&0>xgyIddNCYrQV|hQoGk+)I;G%9^rQ-@>2I* ztsKb@eDE;AT*keadw56IVQw&U;1T}h^wX}digF16P_Wt0+o7tcKNcF^x zPG_9#3GY~b8~@c{&*>rF`w{ow$L3pY-Trv}MEJg6etllqP(zY_vwK`Oe$wWTQ-@>L zUOpy$JNEd@t0U=SeTc0{}{I*s7W0Ui+_LvRPFcA&TLmw zc;Xv4v{vA<<2?51vxyz#kq z$n4f9-#&Vc-Ro=R-wu-obE^`Rwk1kll8Hbl@M(PC%U!Bk50%Jj1v~(3nDXsizym7nF4s?#ld{+ohoITXw zK)^H^w3F{*vb*!exu}XxYEnSJ9jlOmoe%o9iHV0D9fN`#%p3!x zuIk=;)2w^U`H{~(q8sb|-o3WZO7ud`vX!&nG-5TH4VaI|CQleB_>ATsf8t@!9wfiG zu}}5lliK(VIh-maXj61q_E{X(+4pcb3<6o5XvLhjwM+05JmvBwcooeDr`oLeM@eBD-|Q=&qqHO84UX`&%=Jl literal 0 HcmV?d00001 diff --git a/src/assets.rs b/src/assets.rs index 0089cb9..a42f4f2 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -116,6 +116,10 @@ pub struct GameAssets { #[asset(path = "music/bgm.ogg")] pub bgm: Handle, + // --- SOUND --- + #[asset(path = "sounds/strike_sound.ogg")] + pub strike_sound: Handle, + // --- FONT --- #[asset(path = "fonts/PressStart2P.ttf")] pub font: Handle, diff --git a/src/audio/mod.rs b/src/audio/mod.rs index 7c98b9c..67c2112 100644 --- a/src/audio/mod.rs +++ b/src/audio/mod.rs @@ -1,7 +1,6 @@ mod bgm; mod sound; -#[allow(unused_imports)] pub use sound::PlaySound; use bevy::prelude::*; diff --git a/src/player/strike.rs b/src/player/strike.rs index 6d1a655..27a30e3 100644 --- a/src/player/strike.rs +++ b/src/player/strike.rs @@ -5,6 +5,7 @@ use bevy_rapier2d::prelude::*; use bevy_trickfilm::prelude::*; use crate::{ + audio::PlaySound, utils::{quat_from_vec2, FixedRotation}, world::camera::YSort, GameAssets, GameState, @@ -19,6 +20,8 @@ const OFFSET: Vec3 = Vec3::new(0.0, -10.0, 0.0); const CHAIN_COOLDOWN: f32 = 0.35; const STRIKE_COOLDOWN: f32 = 0.4; const STRIKE_CHAIN_COUNT: usize = 3; +const SOUND_PITCH_CHANGE: f64 = 0.1; +const SOUND_VOLUME: f64 = 0.7; #[derive(Resource, Default)] struct StrikeCooldown { @@ -120,6 +123,25 @@ fn despawn_strikes( } } +fn play_strike_sound( + assets: Res, + mut ev_spawn_strike: EventReader, + mut ev_play_sound: EventWriter, +) { + for ev in ev_spawn_strike.read() { + // Lower playback_rate for the last (third) strike + let playback_rate = if ev.strike_index == 2 { 1.0 } else { 1.5 }; + + ev_play_sound.send(PlaySound { + clip: assets.strike_sound.clone(), + volume: SOUND_VOLUME, + rand_speed_intensity: SOUND_PITCH_CHANGE, + playback_rate, + ..default() + }); + } +} + fn trigger_strike( player_input: Res, mouse_coords: Res, @@ -197,6 +219,7 @@ impl Plugin for PlayerStrikePlugin { ( spawn_strikes, despawn_strikes, + play_strike_sound, trigger_strike, reset_chain, tick_strike_cooldown,