Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Turtle issue
#1
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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  wn = turtle.screen() AttributeError: module 'turtle' has no attribute 'screen' Shadower 1 6,171 Feb-06-2019, 01:25 AM
Last Post: woooee
  Help! Turtle not working, even when we click the turtle demo in IDLE nothing happens. BertyBee 3 5,622 Jan-04-2019, 02:44 AM
Last Post: SheeppOSU

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020