Hi all, I’m on a little game engine, but I have a problem,
I init the keyboard like that :
self.accept("arrow_left", self.SetKey, ["xMove", 1, 1])
self.accept("arrow_right", self.SetKey, ["xMove", -1, 1])
self.accept("arrow_up", self.SetKey, ["yMove", 1, 1])
self.accept("arrow_down", self.SetKey, ["yMove", -1, 1])
self.accept("arrow_left-up", self.SetKey, ["xMove", -1, -1])
self.accept("arrow_right-up", self.SetKey, ["xMove", 1, -1])
self.accept("arrow_up-up", self.SetKey, ["yMove", -1, -1])
self.accept("arrow_down-up", self.SetKey, ["yMove", 1, -1])
The SetKey is really simple :
def SetKey(key, value, numKey):
self.keyMap["keys"] += numKey
self.keyMap[key] += value
In the keymap[“keys”] I have the number of key pressed (so I can know when the player stop moving, and change his state, and he can push other key without problems)
Then, the script read the xMove and yMove values and return me the direction.
But, when I click outside my Panda Windows, my player go down forever (I had had a push “r” event to reset him )
I print all of my values, when it bug, I had this :
keys : -4, xMove : 0, yMove : 0
Where the problem, how my script can set -4 to my number of pushed keys ?
Thanks.
(Sorry for my english )