-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (29 loc) · 804 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from turtle import Turtle, Screen
t = Turtle()
screen = Screen()
screen.setup (width=1200, height=900, startx=None, starty=100)
screen.colormode(255)
step_size = 10
shift_range = 10
t.speed("fastest")
def move_forwards():
t.forward(step_size)
def move_backwards():
t.backward(step_size)
def rotate_counterclockwise():
t.setheading(t.heading() + shift_range)
def rotate_clockwise():
t.setheading(t.heading() - shift_range)
def clear():
t.pu()
t.clear()
t.home()
t.pd()
screen.listen()
screen.onkey(key="w", fun=move_forwards)
screen.onkey(key="s", fun=move_backwards)
screen.onkey(key="a", fun=rotate_counterclockwise)
screen.onkey(key="a", fun=rotate_counterclockwise)
screen.onkey(key="d", fun=rotate_clockwise)
screen.onkey(key="c", fun=clear)
screen.exitonclick()