Python Forum
Turtle issue - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Turtle issue (/thread-7640.html)



Turtle issue - Yoavier - Jan-18-2018

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!