Why hello there, im developing a 2D game using XNA. My character movment is currently based on the keyboard state. Example (in the right order):
if (state.IsKeyDown(Keys.W))
{
//Do stuff
}
else if (state.IsKeyDown(Keys.D))
{
//Do Stuff
}
else if (state.IsKeyDown(Keys.A))
{
//Do Stuff
}
else if (state.IsKeyDown(Keys.S))
{
//Do Stuff
}
That way I am able to deny diagonal movment. So my problem is, if "W" is pressed, meaning the character is moving up, And a frame after that while W is still pressed and I press "S" for example, It will keep moving up. I've been looking for a solution for a while and didn't come up with anything good enough. What I need help with is ideas about how to detect if a different key was pressed after W (because it is the first one to check, it doesn't check the others), while denying diagonal movment. Any help would be sincerely appreciated, Thanks in advance.