-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_code.py
More file actions
62 lines (48 loc) · 924 Bytes
/
Copy pathmain_code.py
File metadata and controls
62 lines (48 loc) · 924 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from turtle import *
t=Turtle()
t.color('blue')
t.shape('circle')
t.width(5)
t.speed(0)
def red():
t.color('red')
t.width(5)
def green():
t.color('green')
t.width(5)
def blue():
t.color('blue')
t.width(5)
def eraser():
t.width(20)
t.color('white','grey')
def move(x,y):
t.up()
t.goto(x,y)
t.down()
t.ondrag(t.goto)
scr = t.getscreen()
scr.onscreenclick(move)
scr.listen()
def move_right():
t.goto(t.xcor() + 5, t.ycor())
def move_down():
t.setheading(270)
t.forward(10)
def move_left():
t.setheading(180)
t.forward(10)
def move_up():
t.setheading(90)
t.forward(10)
scr.onkey(move_down, 'Down')
scr.onkey(move_up, 'Up')
scr.onkey(move_left, 'Left')
scr.onkey(move_right, 'Right')
scr.onkey(red,'r')
scr.onkey(green,'g')
scr.onkey(blue,'b')
scr.onkey(eraser,'BackSpace')
scr.onkey(t.begin_fill,'v')
scr.onkey(t.end_fill,'e')
mainloop()