Python Forum

Full Version: Turtle issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Heya, i'm using the turtle module in pycharm community edition 2017.2.3
I am trying to get a simple movement system with a keyboard, using this code:

def right():
    player.goto(player.xcor() + 10, player.ycor())
    print("ay")


def left():
    player.goto(player.xcor() + 10, player.ycor())
    print("hi")



turtle.onkeypress(right(), "Right")
turtle.onkeypress(left(), "Left")
turtle.listen()
for some reason, nothing happens when I press either of the keys.
worth mentioning I also have a loop in the end of the code:

while True:
    cur = player.pos()
    if cur in walls:
        player.forward(x)
        x = x + 0.05
Hopefully it's a simple fix - thanks in advance!