So i have a bool that checks if you have "picked up", then onMouse should be true, if you click again (aka drop it), then it will be false. However, when I click it turns true, then back to false again
sf::RenderWindow window(sf::VideoMode(10,10), "Some Game");
window.setKeyRepeatEnabled(false);
bool onMouse = false;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
if (event.type == event.MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left && !onMouse) {
std::cout << "on Mouse True/Picked up\n";
onMouse = true;
}
if (event.type == event.MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left && onMouse) {
std::cout << "on Mouse False/Dropped\n";
onMouse = false;
}
}
}
I have looked for other similar post, but non have helped my case