aboutsummaryrefslogtreecommitdiff
path: root/src/GameLoop.cpp
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-09-14 23:58:50 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-09-14 23:58:50 +0700
commit0e9c124d6ee480e20be07f955dd0ffe486091a1e (patch)
treea87d21c55315183a38581200464ff73ae56e3867 /src/GameLoop.cpp
parent9505ee252e2670aa40a2c3db7e9101940099f2b2 (diff)
downloadblackshades-0e9c124d6ee480e20be07f955dd0ffe486091a1e.tar.gz
Force menu and hardware cursor
Diffstat (limited to 'src/GameLoop.cpp')
-rw-r--r--src/GameLoop.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp
index 1691157..a927f2f 100644
--- a/src/GameLoop.cpp
+++ b/src/GameLoop.cpp
@@ -39,16 +39,16 @@ void handleKey(Game* game, int key, int action, int mods)
{
if (action != GLFW_PRESS)
return;
- if (game->mainmenu) {
+ if (game->menu) {
if (key == GLFW_KEY_SPACE)
- game->mainmenu = 0;
+ setMenu(game, false);
return;
}
auto& player = game->person[0];
if (key == GLFW_KEY_ESCAPE) {
alSourcePause(gSourceID[rainsound]);
- game->mainmenu = 1;
+ setMenu(game, true);
alSourcePlay(gSourceID[souloutsound]);
game->flashamount = 1.0f;
game->flashr = game->flashg = game->flashb = 1.0f;
@@ -198,6 +198,12 @@ void handleKey(Game* game, int key, int action, int mods)
}
}
+void setMenu(Game* game, bool val)
+{
+ glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR,
+ (game->menu = val) ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED);
+}
+
void eventLoop(Game* game)
{
auto start = glfwGetTime();
@@ -206,7 +212,7 @@ void eventLoop(Game* game)
do multiplier = glfwGetTime() - start;
while (multiplier < 1.0f / 69);
- if (visions == 1 && !game->mainmenu)
+ if (visions == 1 && !game->menu)
multiplier /= 3;
if (slomo)
multiplier /= 5;