I am playing around with Python turtle. So far I can control it with arrow keys, however the direction is near random and I was thinking of resetting the direction that it's facing every time I press an arrow key. However I don't know how to do that exactly. Any help?
import turtle
turtle.color("Red")
turtle.title("Test")
turtle.pensize(5)
def tLeft(): #Edit everything later, most likely to be inaccurate.
turtle.right(180)
turtle.forward(10)
def tRight():
turtle.left(180)
turtle.forward(10)
def tUp():
turtle.right(90)
turtle.forward(10)
def tDown():
turtle.left(270)
turtle.forward(10)
turtle.onkeypress(tUp, "Up")
turtle.onkeypress(tDown, "Down")
turtle.onkeypress(tRight, "Right")
turtle.onkeypress(tLeft, "Left") #First test: When started the code did nothing, nothing showed up and no errors was shown. Edit:only needed "listen()"
turtle.listen()
Sorry if the code looks a little weird :P