I have googled and search these forums for a solution for 30 minutes and can't seem to find anything. It's not a simple google search given the lack of definitions for the problem.
The player moves in 8 directions, using either the NumPad or ArrowKeys/WASD. The NumPad has no problems given its 8 directions are all separate keys. However, arrow keys and WASD require 2 keys down to move diagonally.
if( (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) && (sf::Keyboard::isKeyPressed(sf::Keyboard::Right) )
{
~walk walk walk~
}
Everything works fine, until I want to STOP MOVEMENT while facing a diagonal direction. Input is detected so quickly, that 9 times out of 10 you will end up facing N, E, S, W- because even a faster user cannot release both keys at the exact same time. One key is always released after the other.
I've read a little bit about ONE possible solution: Taking out the logic in the keyboard if's, and replace it with a variable.
I am new to SFML, so I am not sure this is the best way to handle this. I would prefer not to slow down detection of input either, or make overcomplicated code if there is an easier way to fix this.
Thank you- I am sure any help to solve this will help me save hours of time trying to solve it or research the deepest depths of google to find the logic behind this instead of diagonal speed (sin / cos). The engineering is pretty simple if I remember correctly, which is why I ask for a solution. I actually remember long ago kind of how I handled it in a different framework, but I do not remember enough to get it done quickly.