diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GameInitDispose.cpp | 18 | ||||
-rw-r--r-- | src/GameTick.cpp | 24 | ||||
-rw-r--r-- | src/Person.cpp | 25 |
3 files changed, 27 insertions, 40 deletions
diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp index 600a6a4..0022a07 100644 --- a/src/GameInitDispose.cpp +++ b/src/GameInitDispose.cpp @@ -109,12 +109,21 @@ Game* makeGame(Config config) void LoadSounds(bool musictoggle) { + gSampleSet[footstepsound + 0] = loadSound("footstep/0.ogg"); + gSampleSet[footstepsound + 1] = loadSound("footstep/1.ogg"); + gSampleSet[footstepsound + 2] = loadSound("footstep/2.ogg"); + gSampleSet[footstepsound + 3] = loadSound("footstep/3.ogg"); + gSampleSet[footstepsound + 4] = loadSound("footstep/4.ogg"); gSampleSet[clicksound] = loadSound("gun/empty-clip.wav"); gSampleSet[shotgunsound] = loadSound("gun/fire/20-gauge-shotgun.wav"); gSampleSet[pistol2sound] = loadSound("gun/fire/22-magnum-pistol.wav"); gSampleSet[pistol1sound] = loadSound("gun/fire/9-mm-pistol.wav"); gSampleSet[machinegunsound] = loadSound("gun/fire/ar-15-pistol.wav"); gSampleSet[riflesound] = loadSound("gun/fire/ar-15-rifle.wav"); + gSampleSet[nearbulletsound] = loadSound("gun/near-bullet.wav"); + gSampleSet[reloadsound] = loadSound("gun/reload.wav"); + gSampleSet[pinpullsound] = loadSound("grenade/pin-pull.flac"); + gSampleSet[pinreplacesound] = loadSound("grenade/pin-replace.flac"); gSampleSet[bodylandsound] = loadSound("impact/body-fall.wav"); gSampleSet[bodyhitsound] = loadSound("impact/body-hit.wav"); gSampleSet[knifeslashsound] = loadSound("impact/knife-stab.wav"); @@ -123,18 +132,9 @@ void LoadSounds(bool musictoggle) gSampleSet[visionsound] = loadSound("underwater.ogg"); gSampleSet[soulinsound] = loadSound("soul-in.ogg"); gSampleSet[souloutsound] = loadSound("soul-out.ogg"); - gSampleSet[footstepsound + 0] = loadSound("footstep1.ogg"); - gSampleSet[footstepsound + 1] = loadSound("footstep2.ogg"); - gSampleSet[footstepsound + 2] = loadSound("footstep3.ogg"); - gSampleSet[footstepsound + 3] = loadSound("footstep4.ogg"); - gSampleSet[footstepsound + 4] = loadSound("footstep5.ogg"); gSampleSet[headlandsound] = loadSound("headland.ogg"); - gSampleSet[nearbulletsound] = loadSound("Nearbullet.ogg"); gSampleSet[headwhacksound] = loadSound("riflewhack.ogg"); gSampleSet[headshotsound] = loadSound("headshot.ogg"); - gSampleSet[reloadsound] = loadSound("reload.ogg"); - gSampleSet[pinpullsound] = loadSound("pinpull.ogg"); - gSampleSet[pinreplacesound] = loadSound("pinreplace.ogg"); gSampleSet[grenadethrowsound] = loadSound("handlerelease.ogg"); gSampleSet[bouncesound] = loadSound("bounce.ogg"); gSampleSet[bounce2sound] = loadSound("bounce2.ogg"); diff --git a/src/GameTick.cpp b/src/GameTick.cpp index 3b9cf5a..4e75895 100644 --- a/src/GameTick.cpp +++ b/src/GameTick.cpp @@ -198,7 +198,7 @@ void click(Game* game, int button, int action, int mods) if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS && player.attackframe < 0 && (!player.aiming || player.ammo <= 0 - || weapon == nogun || weapon == knife || weapon == grenade + || weapon == nogun || weapon == knife || player.targetanimation == joganim) && player.targetanimation != diveanim && player.targetanimation != throwanim) { @@ -288,9 +288,8 @@ void click(Game* game, int button, int action, int mods) && player.reloading <= 0 && player.attackframe < 0) { auto& skeleton = player.skeleton; auto& hand = skeleton.joints[skeleton.jointlabels[righthand]]; - auto soundsrc = (DoRotation(hand.position, 0, player.playerrotation, 0) - + player.playercoords - camera.position) / soundscalefactor; - float gLoc[] {soundsrc.x, soundsrc.y, soundsrc.z}; + auto soundsrc = DoRotation(hand.position, 0, player.playerrotation, 0) + + player.playercoords - camera.position; if (player.grenphase) { if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE) { // throw @@ -301,15 +300,15 @@ void click(Game* game, int button, int action, int mods) } else if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) { // put pin back player.grenphase = false; - alSourcefv(gSourceID[pinreplacesound], AL_POSITION, gLoc); - alSourcePlay(gSourceID[pinreplacesound]); + playSound(gSourceID[pinreplacesound], + soundsrc.x, soundsrc.y, soundsrc.z); } } else { if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) { // pull pin player.grenphase = true; - alSourcefv(gSourceID[pinpullsound], AL_POSITION, gLoc); - alSourcePlay(gSourceID[pinpullsound]); + playSound(gSourceID[pinpullsound], + soundsrc.x, soundsrc.y, soundsrc.z); } } } @@ -2460,13 +2459,8 @@ void Game::Tick() && findDistancefast(nearest, camera.position) < 10 && (thirdperson == 2 || j != 0)) { auto nearsound = nearest - camera.position; - ALfloat gLoc[] { - nearsound.x / soundscalefactor, - nearsound.y / soundscalefactor, - nearsound.z / soundscalefactor, - }; - alSourcefv(gSourceID[nearbulletsound], AL_POSITION, gLoc); - alSourcePlay(gSourceID[nearbulletsound]); + playSound(gSourceID[nearbulletsound], + nearsound.x, nearsound.y, nearsound.z); } } } diff --git a/src/Person.cpp b/src/Person.cpp index bd1e5cb..f5eb314 100644 --- a/src/Person.cpp +++ b/src/Person.cpp @@ -213,12 +213,9 @@ void Person::DoAnimations(int who) && (targetanimation == joganim || targetanimation == walkanim) && (targetframe == 0 || targetframe == 8) && who == 0) { - auto soundsrc = (playercoords - camera.position) - / soundscalefactor; - ALfloat gLoc[] {soundsrc.x, soundsrc.y, soundsrc.z}; - int whichsound = footstepsound + abs(Random()) % 5; - alSourcefv(gSourceID[whichsound], AL_POSITION, gLoc); - alSourcePlay(gSourceID[whichsound]); + auto soundsrc = playercoords - camera.position; + playSound(gSourceID[footstepsound + abs(Random()) % 5], + soundsrc.x, soundsrc.y, soundsrc.z); } if (targetanimation == zombieeatanim && targetframe == 3) { @@ -531,10 +528,9 @@ void Person::DoAnimations(int who) ALint tempint; alGetSourcei(gSourceID[reloadsound], AL_SOURCE_STATE, &tempint); if (whichgun != grenade && tempint != AL_PLAYING) { - auto soundsrc = (playercoords - camera.position) / soundscalefactor; - ALfloat gLoc[] {soundsrc.x, soundsrc.y, soundsrc.z}; - alSourcefv(gSourceID[reloadsound], AL_POSITION, gLoc); - alSourcePlay(gSourceID[reloadsound]); + auto soundsrc = playercoords - camera.position; + playSound(gSourceID[reloadsound], + soundsrc.x, soundsrc.y, soundsrc.z); } reloading = 3; aiming = 0; @@ -581,12 +577,9 @@ void Person::DoAnimationslite(int who) && (targetanimation == joganim || targetanimation == walkanim) && (targetframe == 0 || targetframe == 8)) { - auto soundsrc = (playercoords - camera.position) - / soundscalefactor; - ALfloat gLoc[] {soundsrc.x, soundsrc.y, soundsrc.z}; - int whichsound = footstepsound + abs(Random()) % 5; - alSourcefv(gSourceID[whichsound], AL_POSITION, gLoc); - alSourcePlay(gSourceID[whichsound]); + auto soundsrc = playercoords - camera.position; + playSound(gSourceID[footstepsound + abs(Random()) % 5], + soundsrc.x, soundsrc.y, soundsrc.z); } if (targetanimation == zombieeatanim && targetframe == 3) { |