'( Python ) Program doesn't respond to inputs ( key press or click )
I'm using the Turtle librarie in Python. My program isn't detecting that I press a key.
def jump():
if player.ground == True:
player.dy += 10
game.listen()
game.onkeypress(jump, "w")
This is the code and I think it should work based on the tutorials I have seen. I also tried the code like this but it doesn't work either.
def jump():
if player.ground == True:
player.dy += 10
game.listen()
game.onkeypress(jump(), "w")
Adding the parenthesis on the last line doesn't seem to help.
Help me pls :(
Solution 1:[1]
First I think you should put game.listen() after game.onkeypress().
And make sure that you have a loop that updates the game. And if you are able can you post the full code. For more information you can search some youtube videos about making a game with python turtle or you can go to: https://docs.python.org/3/library/turtle.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | AABULUT |
