forked from selennazlib/CodeInPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (26 loc) · 612 Bytes
/
Copy pathmain.py
File metadata and controls
33 lines (26 loc) · 612 Bytes
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
from turtle import Turtle, Screen
tt = Turtle()
tt.color('purple')
tt.speed('fastest')
screen = Screen()
def move_forward():
tt.forward(20)
def move_backward():
tt.backward(20)
def counter_clockwise():
tt.left(20)
def clockwise():
tt.right(20)
def clear():
tt.clear()
tt.penup()
tt.home()
tt.pendown()
screen.listen()
# listens for screen / window inputs.
screen.onkey(key="w", fun=move_forward)
screen.onkey(key="s", fun=move_backward)
screen.onkey(key="a", fun=counter_clockwise)
screen.onkey(key="d", fun=clockwise)
screen.onkey(key="e", fun=clear)
screen.exitonclick()