diff options
| author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-09-14 23:58:50 +0700 |
|---|---|---|
| committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-09-14 23:58:50 +0700 |
| commit | 0e9c124d6ee480e20be07f955dd0ffe486091a1e (patch) | |
| tree | a87d21c55315183a38581200464ff73ae56e3867 /src/GameLoop.cpp | |
| parent | 9505ee252e2670aa40a2c3db7e9101940099f2b2 (diff) | |
| download | blackshades-0e9c124d6ee480e20be07f955dd0ffe486091a1e.tar.gz | |
Force menu and hardware cursor
Diffstat (limited to 'src/GameLoop.cpp')
| -rw-r--r-- | src/GameLoop.cpp | 14 |
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; |
