forked from kokonior/Python-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScalable-Snowman.py
More file actions
111 lines (88 loc) · 1.97 KB
/
Scalable-Snowman.py
File metadata and controls
111 lines (88 loc) · 1.97 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import turtle
radius1 = float(input("What radius for the first circle?: "))
radius2 = float(input("What radius for the second circle?: "))
radius3 = float(input("What radius for the third circle?: "))
turtle.speed(0)
turtle.hideturtle()
turtle.bgcolor("black")
def Snowman(x, y, radius1, radius2, radius3):
turtle.goto(x, y)
turtle.color("lightblue")
#head
turtle.begin_fill()
turtle.circle(radius1)
turtle.end_fill()
turtle.up()
#body piece 1
turtle.right(90)
turtle.forward(radius2*2)
turtle.left(90)
turtle.begin_fill()
turtle.circle(radius2)
turtle.end_fill()
turtle.up()
#body piece 2
turtle.right(90)
turtle.forward(radius3*2)
turtle.left(90)
turtle.begin_fill()
turtle.circle(radius3)
turtle.end_fill()
#eyes
turtle.color("blue")
turtle.left(90)
turtle.forward(radius3*2+radius2*2+radius1)
turtle.left(-90)
turtle.forward(radius1/2)
turtle.begin_fill()
turtle.circle(radius1/6)
turtle.end_fill()
turtle.left(180)
turtle.forward(radius1)
turtle.right(180)
turtle.begin_fill()
turtle.circle(radius1/6)
turtle.end_fill()
#nose
turtle.forward(radius1/2)
turtle.right(90)
turtle.color("orange")
turtle.begin_fill()
turtle.forward(radius1/2)
turtle.left(120)
turtle.forward(radius1/2)
turtle.left(120)
turtle.forward(radius1/2)
turtle.end_fill()
#buttons
turtle.setheading(270)
turtle.forward(radius1)
for x in range(3):
turtle.forward(radius2/2)
turtle.begin_fill()
turtle.circle(radius1/6)
turtle.end_fill()
turtle.left(90)
def draw():
turtle.tracer(0, 0)
Snowman(x, y, radius1, radius2, radius3)
Snowman(x+120, y, radius1, radius2, radius3)
Snowman(x+-120, y, radius1, radius2, radius3)
turtle.update()
def left():
global x
turtle.clear()
x-=10
draw()
def right():
global x
turtle.clear()
x+=10
draw()
x = 0
y = 0
draw()
turtle.onkeypress(left, "a")
turtle.onkeypress(right, "d")
turtle.listen()
turtle.mainloop()