1
General / Movement related question
« on: July 09, 2018, 10:14:55 pm »
Hi. I have a simple question related to moving player.
Casual move function looks like this:
When you press LEFT and RIGHT key in the same time player doesn't move at all and it's good. But my problem is that I want it to stay stopped when I release keys in the same time, but it's not. I know that it's related to the fact the it's hard to release to keys in the same time, but I want to know the method to ease it.
Casual move function looks like this:
if(sf::Keyboard::isKeyPressed(left)) player.move(-100, 0);
if(sf::Keyboard::isKeyPressed(right)) player.move(100, 0);
if(sf::Keyboard::isKeyPressed(right)) player.move(100, 0);
When you press LEFT and RIGHT key in the same time player doesn't move at all and it's good. But my problem is that I want it to stay stopped when I release keys in the same time, but it's not. I know that it's related to the fact the it's hard to release to keys in the same time, but I want to know the method to ease it.