summary refs log tree commit diff
path: root/src/GameLoop.cpp
diff options
context:
space:
mode:
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;