From 810e07cc446b527f01bf906fd187b75fd42a5cf6 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 19 Nov 2022 16:48:30 +0100 Subject: [PATCH] Add foodsteps --- .../sounds/effects/steps/steps_indoor_1.mp3 | Bin 0 -> 2996 bytes .../sounds/effects/steps/steps_indoor_2.mp3 | Bin 0 -> 3716 bytes .../sounds/effects/steps/steps_indoor_3.mp3 | Bin 0 -> 2996 bytes assets/sounds/effects/steps_indoor.mp3 | Bin 3212 -> 0 bytes .../src/main/kotlin/com/last/commit/Player.kt | 12 +++++-- .../com/last/commit/audio/GameSoundEffect.kt | 8 ++++- .../com/last/commit/audio/SoundEngine.kt | 32 +++++++++--------- 7 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 assets/sounds/effects/steps/steps_indoor_1.mp3 create mode 100644 assets/sounds/effects/steps/steps_indoor_2.mp3 create mode 100644 assets/sounds/effects/steps/steps_indoor_3.mp3 delete mode 100644 assets/sounds/effects/steps_indoor.mp3 diff --git a/assets/sounds/effects/steps/steps_indoor_1.mp3 b/assets/sounds/effects/steps/steps_indoor_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..14a9874525b522a9d25b451be9acb14facd5875d GIT binary patch literal 2996 zcmdUxc{J4PAIHD5*vEQ@Yotu}G-Qa2$i7SrW1m6xB}-(j>#7-}7(z_Q(tC9=%lveHzx#)Oe}DYW`Mu70pU-(d&vVZ6dCv2Bp7X|-s6zn*005*9 z1Op*C0H|4nlLO8a{d0UE6R*%fzYwHZSkwjfyoK*U<}moc(13%C;DNXRfR6%5AA)d* z%tO37%)%jd4#7Ue!Cp8kL#(N~3R+bas`yVq8r-r_J!Js&{%0LGbeZ}8O#F``dmir# z@MwWfo+<&&WBy@aD(vPz~Sl0sv650&}+Y67gx6iVn5FrCHjI@^o1h7e6?62>)iEOAO zNI*%r0%{~(DtmB;mB|nWG?4?In*|PgvvVungu&o*NZUGR8#Qd&a2;)-$^c|63arv) z&Ri%N4)#%kr7CF#hipo4p665m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0 zgwwkn!d(5Gh5Pru+mw}jYs?>dK`v0P2WO9w^9#21__LJGHheD%r$9RTQ=V=e4R>da z5aad!+&XPlpr!XJ(-oS-2mZ95ZIzS_+QPHIt;!~x>Ui!u(JIUFE9wR7#k9lbEdpG+ z$hBRrO4q?EJtuH$E39F{g-LZB7us@o*WH|aC_9HCRfSbkuFt&nhqkV?_#f4g)!y-Q zT|@X+$-h!_&(w&Vtt@@&hREh&aOOPJ*L;qDt33H8rj|llpcC3L+z&)Cf0C^cw7=eP zui?dvDa&a7EMeKeU_07pv`j9*TQIw#lZ)3QcF;G$Ek1Pu8n;I2VTBQvwjFq zx)65x&gL8Y4`?~XJoLAXS!?x|c6u!$B0)~#=hudXr867&)iiD1bZ#(wsj+eQRp>w9 z5+o8i3*}GW^;Ytv`arE&w-1YR)Ak?hM_Jiw+Cb018;R-z7M7C)p{%0*g|9k!~|G&TW-)W^S31Wr- SfbRFd_A7>8fAs$&)qesZlwqp? literal 0 HcmV?d00001 diff --git a/assets/sounds/effects/steps/steps_indoor_3.mp3 b/assets/sounds/effects/steps/steps_indoor_3.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..02dbf87f6232b0747f9d0e6dd62675b8c8ced573 GIT binary patch literal 2996 zcmd6pc{tSV8pnS#W-LRt2;pta$j(@jcvZuUWsrAbXehFbJ(8`aFk_3!%t=JX5-LhH z%9=?ers=hNvm_)#TFBO7otmTTocCOpf6pK1I-l$MUeER1_aD#qpXa{6IIIZ-Km!1P z*pdVY4h0~#QSJo1jnS|Bmax7NApxi0wx?r)1=IGVt;%+YArV1a6{#(W0DyP~fY^rX zHZE=B@pj&9V|^QfZEU@Tcd|NSV`5-rXb92z+mNZKx{#_q0Gj;e1GQ@;=kLb<=oCy7 zNr2cm2#G2M01zGwFGB-hh_WR)Oi&8inLZ<&GRfcb9W0qLxppYNk+P1VQsI*?*5FY* zI9wDAO8>Gb;7D^CDbiq(L!~dYmjSp`%7?Y0J%<2@BxNV9U9bdKgE&*JN!>L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hy4HT6;*-SBcyUCPr&9=}Rx`GHpEf!%P0PbvU*Pu>(Gke3p0Pl2Z z=~g5+jW{*Q4T|NtTq`Qf6qHKn+1i?tN)o~gfaz!AuAG{+^g4n}0E#`t!61f{6^yqc zVbYG`?p+CoLpaz1V|X$c>j|gRO#na=h5)k((utt_aUu^L&9dmvWWW$sA+UykGS8;o ztQ<>8=8}ayuULcHi(b8fGs-pT$H+>35Szy`b{QK0B>Rq4!DXR%(!tzD7p+1ofjT}C zRh8)G*G+s}y!4}ga#S5>j-vWKc@(R0E>d?$0EP|Iv%Rc1a#u>eFtA?Y)jL(+lUDtH zHV&=OK8@mA8ux1YolmD;YY1CP?(m;U%reGxQ>;sy4pL@f##Uvj##bb;Heg!GjgOft;bM`Z{!I%a5n`jv9^D%O*!Mr5n$sj54L=cBuJ(La zzUw@F+V5WW-Ab{ng34th5nfiVj(Pf8or_9NlEJK3wMDjd^+K@{u9$|aH?eNcUcaE} zxp}>s|9Oy8R>$SVofaq3YBo+I72p=j|s2Jalt5yrl44gpr3U}@JRZQ z30mQnxEXv1+j-n2;&_Byr>erVnx@Yob9*#mQ0Y zJ*OWtROh|mM 500) { + gameState.soundEngine.play(GameSoundEffect.STEPS_INDOOR, 0.5f) + lastStep = System.currentTimeMillis() + } + } } private fun updatePosition(v: Vector2, delta: Float) { diff --git a/core/src/main/kotlin/com/last/commit/audio/GameSoundEffect.kt b/core/src/main/kotlin/com/last/commit/audio/GameSoundEffect.kt index 424ce22..c45673d 100644 --- a/core/src/main/kotlin/com/last/commit/audio/GameSoundEffect.kt +++ b/core/src/main/kotlin/com/last/commit/audio/GameSoundEffect.kt @@ -4,7 +4,13 @@ import com.last.commit.audio.GameSound public class GameSoundEffect(name: String): GameSound(name) { companion object { - val STEPS_INDOOR = GameSoundEffect("steps_indoor.mp3") + val STEPS_INDOOR: GameSoundEffect + get() = listOf( + GameSoundEffect("steps/steps_indoor_1.mp3"), + GameSoundEffect("steps/steps_indoor_2.mp3"), + GameSoundEffect("steps/steps_indoor_3.mp3"), + ).random() + val DOOR_OPEN = GameSoundEffect("door_open.mp3") val DOOR_CLOSE = GameSoundEffect("door_close.mp3") } diff --git a/core/src/main/kotlin/com/last/commit/audio/SoundEngine.kt b/core/src/main/kotlin/com/last/commit/audio/SoundEngine.kt index cb674d0..d1dd402 100644 --- a/core/src/main/kotlin/com/last/commit/audio/SoundEngine.kt +++ b/core/src/main/kotlin/com/last/commit/audio/SoundEngine.kt @@ -1,18 +1,17 @@ -package com.last.commit.audio; +package com.last.commit.audio import com.badlogic.gdx.Gdx -import com.badlogic.gdx.audio.Sound import com.badlogic.gdx.audio.Music -import com.last.commit.audio.GameSound -import com.last.commit.audio.GameMusic - +import com.badlogic.gdx.audio.Sound public class SoundEngine { - private val sounds: HashMap = HashMap() - private val musicTracks: HashMap = HashMap() - - public fun play(gameSound: GameSound, volume: Float = 1f) { + private val sounds: ThreadLocal> = + ThreadLocal.withInitial() { HashMap() } + private val musicTracks: ThreadLocal> = + ThreadLocal.withInitial() { HashMap() } + + fun play(gameSound: GameSound, volume: Float = 1f) { if (gameSound is GameSoundEffect) { val sound = loadEffect(gameSound.name) sound.play(volume) @@ -24,28 +23,29 @@ public class SoundEngine { music.play() } } - - private fun loadEffect(name: String): Sound { + + private fun loadEffect(name: String): Sound { return loadSound("effects/$name") } private fun loadMusic(name: String): Music { - var music = musicTracks.get(name) + var music = musicTracks.get().get(name) + if (music == null) { println("Loading sound $name") - music = Gdx.audio.newMusic(Gdx.files.internal("sounds/music/$name")) - musicTracks[name] = music + music = Gdx.audio.newMusic(Gdx.files.internal("sounds/music/$name")) + musicTracks.get()[name] = music } return music!! } private fun loadSound(name: String): Sound { - var sound = sounds.get(name) + var sound = sounds.get().get(name) if (sound == null) { println("Loading sound $name") sound = Gdx.audio.newSound(Gdx.files.internal("sounds/$name")) - sounds[name] = sound + sounds.get()[name] = sound } return sound!!