aboutsummaryrefslogtreecommitdiff
path: root/src/GameLoop.cpp
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-10-29 12:12:20 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-10-29 12:12:59 +0700
commit3a6ee8b91ede5fc9432643c33272e34d878d009c (patch)
treed79ee0087596ddc4b2ed2122ccf3427689ec1265 /src/GameLoop.cpp
parent9953dae353e6166946e21430f63854927d1db2d7 (diff)
downloadblackshades-3a6ee8b91ede5fc9432643c33272e34d878d009c.tar.gz
Make cheat keys configurable
Diffstat (limited to 'src/GameLoop.cpp')
-rw-r--r--src/GameLoop.cpp39
1 files changed, 14 insertions, 25 deletions
diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp
index cc383c8..3364bc2 100644
--- a/src/GameLoop.cpp
+++ b/src/GameLoop.cpp
@@ -158,30 +158,21 @@ void handleKey(Game* game, int key, int action, int mods)
if (!game->debug)
return;
- const auto shift = mods & GLFW_MOD_SHIFT;
- XYZ facing;
-
- switch(key) {
- case GLFW_KEY_TAB:
+ if (key == keymap.switch_view) {
thirdperson = (thirdperson == 2) ? 0 : (thirdperson + 1);
- break;
- case GLFW_KEY_K:
+ } else if (key == keymap.skip) {
game->timeremaining = 0;
- break;
- case GLFW_KEY_B:
+ } else if (key == keymap.pause) {
alSourcePlay(gSourceID[soulinsound]);
- if (shift) {
- game->paused = 1 - game->paused;
- } else {
- auto pitch = (slomo ^= 1) ? 0.5f : 1.0f;
- alSourcef(gSourceID[knifesong], AL_PITCH, pitch);
- alSourcef(gSourceID[shootsong], AL_PITCH, pitch);
- alSourcef(gSourceID[zombiesong], AL_PITCH, pitch);
- }
- break;
- case GLFW_KEY_F:
- facing = {0, 0, -1};
- facing = DoRotation(facing, -camera.rotation2, 0, 0);
+ game->paused = 1 - game->paused;
+ } else if (key == keymap.slomo) {
+ alSourcePlay(gSourceID[soulinsound]);
+ auto pitch = (slomo ^= 1) ? 0.5f : 1.0f;
+ alSourcef(gSourceID[knifesong], AL_PITCH, pitch);
+ alSourcef(gSourceID[shootsong], AL_PITCH, pitch);
+ alSourcef(gSourceID[zombiesong], AL_PITCH, pitch);
+ } else if (key == keymap.force) {
+ auto facing = DoRotation({0, 0, -1}, -camera.rotation2, 0, 0);
facing = DoRotation(facing, 0, 0 - camera.rotation, 0);
alSourcePlay(gSourceID[souloutsound]);
@@ -208,17 +199,15 @@ void handleKey(Game* game, int key, int action, int mods)
joint.velocity.z += abs(Random() % 20) - 10;
}
}
- break;
- case GLFW_KEY_X:
+ } else if (key == keymap.switch_weapon) {
if (player.grenphase)
- break;
+ return;
player.grenphase = 0;
player.ammo = -1;
player.whichgun++;
if (player.whichgun > 7)
player.whichgun = 0;
player.reloads[player.whichgun] = 3;
- break;
}
}