I think that you’ll find that the problem is the else after the troublesome pair.
As you currently have it, I believe that it is related to the latter of the two (whichever that is at the time). Thus, we could see the following situations (taking the order given in the picture), I believe, with the following results, I think:
-
“Down” is pressed, “up” is pressed:
Two opposing movements are made. Since “down”'s code gets executed first, and sets the flag that prevents it for “up”, only “down”'s animation plays.
-
“Down” is not pressed, “up” is pressed:
The first if-statement is skipped (since “down” is not pressed), the player moves in response to the “up” press, and “up”'s animation plays.
-
“Down” is not pressed, “up” is pressed:
Both if-statements are skipped (since neither key is down), and the else is run.
-
“Down” is pressed, “up” is not:
The first if-statement runs, moving the character and starting the animation. Then, because the second if-statement fails (since “up” is not pressed), the else runs, including the pose.
I think, at least, that that is your problem.
If so, then you might solve it, I think, by either setting a boolean in each if-statement, before their inner if-statements, and test that instead of using the final else statement, something like this:
hasMoved = False
if self.keyMap["down"] == 1:
#Note that the brackets aren't, I don't think, called for above ;)
hasMoved = True
self.gabriel.setY(self.gabriel, timing*4)
# ... etc.
if self.keyMap["up"] == 1:
hasMoved = True
self.gabriel.setY(self.gabriel, -timing*4)
# ... etc.
if not hasMoved:
self.gabriel.stop()
# ... etc.
Otherwise, you might test both “up” and “down” in an over-arching if-statement, and then have your else relate to that, along these lines:
if self.keyMap["up"] == 1 or self.keyMap["down"] == 1:
if self.keyMap["down"] == 1:
# ... etc.
if self.keyMap["up"] == 1:
# ... etc.
else:
self.gabriel.stop()
# ... etc.
There may well be other solutions, and I may well be wrong about the problem, but that is what comes to mind to me.