My question is how do I make a character move in only the direction of the last arrow key input.
So if you press up the character moves upward and then press left without letting go of the up arrow, the character stops moving up and then moves left instead. I have tried and I presume the solution is incredibly simple but it just doesn't want to reveal itself to me.
Here is the code I currently tried, it works but only in one of the axis, when moving up or down the character will change direction if you press either the left or right keys. However if you start with the left or right keys, then the character doesn't change when you press the up or down.
else if(input.right.isPressed()) mx++;
else if(input.up.isPressed()) my--;
else if(input.down.isPressed()) my++;
I have also tried to make it that when you press one of the arrow keys all the other keys are released and that had the same result as this code, one axis it works and the other it does not.
Sorry if it is difficult to understand the question, my brain is fried from trying to figure this out, the quality of the question could be ruined because of that.