diff options
| author | Nguyễn Gia Phong <cnx@loang.net> | 2023-11-19 05:08:01 +0900 |
|---|---|---|
| committer | Nguyễn Gia Phong <cnx@loang.net> | 2023-11-19 05:08:01 +0900 |
| commit | e68d3ee2380dba98a72f2668a2c2664fc993bb4a (patch) | |
| tree | 8aaabd3bc11b16b31c67fe2667ad8a6542327ef1 /src/GameLoop.cpp | |
| parent | db730f01951231196cac36630d043c7a3676d446 (diff) | |
| download | blackshades-e68d3ee2380dba98a72f2668a2c2664fc993bb4a.tar.gz | |
Fix off-by-one music selection
Fixes: https://todo.sr.ht/~cnx/blackshades/25
Diffstat (limited to 'src/GameLoop.cpp')
| -rw-r--r-- | src/GameLoop.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp index 66b7395..da531e1 100644 --- a/src/GameLoop.cpp +++ b/src/GameLoop.cpp @@ -41,23 +41,18 @@ void handleKey(Game* game, int key, int action, int mods) return; auto& player = game->person[0]; if (key == GLFW_KEY_ESCAPE) { - alSourcePause(gSourceID[rainsound]); - setMenu(game, true); + alSourceStop(gSourceID[rainsound]); + alSourceStop(gSourceID[visionsound]); + if (game->musictoggle) { + alSourceStop(gSourceID[game->whichsong]); + game->whichsong = mainmenusong; + alSourcef(gSourceID[game->whichsong], AL_PITCH, 1); + alSourcePlay(gSourceID[game->whichsong]); + } alSourcePlay(gSourceID[souloutsound]); + setMenu(game, true); game->flashamount = 1.0f; game->flashr = game->flashg = game->flashb = 1.0f; - alSourceStop(gSourceID[visionsound]); - game->whichsong = mainmenusong; - alSourceStop(gSourceID[knifesong]); - alSourceStop(gSourceID[shootsong]); - alSourceStop(gSourceID[zombiesong]); - alSourceStop(gSourceID[mainmenusong]); - alSourcef(gSourceID[knifesong], AL_MIN_GAIN, 0); - alSourcef(gSourceID[shootsong], AL_MIN_GAIN, 0); - alSourcef(gSourceID[zombiesong], AL_MIN_GAIN, 0); - alSourcef(gSourceID[mainmenusong], AL_MIN_GAIN, 0); - alSourcePlay(gSourceID[game->whichsong]); - alSourcef(gSourceID[game->whichsong], AL_MIN_GAIN, 1); } else if (key == keymap.dive) { if (player.playerrotation == player.playerlowrotation && player.targetanimation == joganim |
