diff options
-rw-r--r-- | src/GameTick.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/GameTick.cpp b/src/GameTick.cpp index 4182c71..9630a1b 100644 --- a/src/GameTick.cpp +++ b/src/GameTick.cpp @@ -108,7 +108,7 @@ void Game::updateSong() void click(Game* game, int button, int action, int mods) { if (game->menu) { - if (button != GLFW_MOUSE_BUTTON_LEFT || action != GLFW_PRESS) + if (button != GLFW_MOUSE_BUTTON_LEFT) return; double xpos, ypos; auto window = glfwGetCurrentContext(); @@ -116,12 +116,18 @@ void click(Game* game, int button, int action, int mods) double mousex = xpos * 640 / game->screenwidth; double mousey = 480 - ypos * 480 / game->screenheight; - game->mouseoverbutton = 0; + auto button = 0; if (mousex > 120 && mousex < 560) { if (mousey > 235 && mousey < 305) - game->mouseoverbutton = 1; + button = 1; else if (mousey > 112 && mousey < 182) - game->mouseoverbutton = 2; + button = 2; + } + if (action == GLFW_PRESS) { + game->mouseoverbutton = button; + return; + } else if (button != game->mouseoverbutton) { + game->mouseoverbutton = 0; } switch (game->mouseoverbutton) { @@ -156,6 +162,7 @@ void click(Game* game, int button, int action, int mods) alSourcePlay(gSourceID[losesound]); break; } + game->mouseoverbutton = 0; return; } |