Untitled
unknown
python
3 years ago
752 B
9
Indexable
import turtle
from turtle import *
turtle_screen = Screen()
turtle_screen.bgcolor('yellow')
turtle_screen.title('Movement')
bob_the_turtle = Turtle()
bob_the_turtle.color('red')
bob_the_turtle.speed(2)
bob_the_turtle.shape('turtle')
def up():
bob_the_turtle.setheading(90)
bob_the_turtle.forward(100)
def down():
bob_the_turtle.setheading(270)
bob_the_turtle.forward(100)
def left():
bob_the_turtle.setheading(180)
bob_the_turtle.forward(100)
def right():
bob_the_turtle.setheading(0)
bob_the_turtle.forward(100)
def r():
bob_the_turtle.clear()
onkey(up, 'Up')
onkey(down, 'Down')
onkey(right, 'Right')
turtle.onkey(left, 'Left')
onkey(r, '7')
listen()
turtle.mainloop()
turtle_screen.exitonclick()
Editor is loading...