diff options
author | Stephen Enders <smenders@gmail.com> | 2021-01-18 16:26:18 -0500 |
---|---|---|
committer | Stephen Enders <smenders@gmail.com> | 2021-01-18 16:31:31 -0500 |
commit | 367292e545f5a15e9dc68d60e5f4fe6835eecce1 (patch) | |
tree | f3635648e3db3591204970c3fb178387dd7cf081 | |
parent | de6d60a1ce9bc3223bc80f9cac7d03a16c63d8b2 (diff) |
Lock mouse click
-rw-r--r-- | ur.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -13,6 +13,8 @@ const sf::Color SEMI_TRANSPARENT = sf::Color(0xff, 0x0, 0xff, 255); GameState state = GameState::WAITING; GameState prev_state = GameState::WAITING; +bool mouse_left_locked = false; + inline void change_state(GameState next) { @@ -177,7 +179,9 @@ main() window.close(); } - if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { + if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left) && + !mouse_left_locked) { + mouse_left_locked = true; // check rolling button click window.setView(view); auto mPos = window.mapPixelToCoords(sf::Mouse::getPosition(window)); @@ -211,6 +215,8 @@ main() } } window.setView(window.getDefaultView()); // reset back to main view + } else if (!sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { + mouse_left_locked = false; } } |