-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturtle_pr.py
More file actions
99 lines (80 loc) · 1.46 KB
/
turtle_pr.py
File metadata and controls
99 lines (80 loc) · 1.46 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
from turtle import Turtle
from random import randint
import turtle
import time
# WINDOW
window = turtle.Screen()
window.title('Turtle race')
turtle.bgcolor('purple')
turtle.speed(0)
turtle.penup()
turtle.setpos(-140,200)
turtle.write('Turtle race',font=('Arial',30,'bold'))
turtle.penup()
#
turtle.setpos(-1200,-180)
turtle.color('red')
turtle.begin_fill()
turtle.pendown()
turtle.forward(3000)
turtle.right(90)
turtle.forward(500)
turtle.right(90)
turtle.forward(3000)
turtle.right(90)
turtle.forward(500)
turtle.end_fill()
# finish line
stamp_size=20
square_size=15
finish_line = 200
turtle.color('black')
turtle.shape('square')
turtle.shapesize(square_size/stamp_size)
turtle.penup()
for i in range(10):
turtle.setpos(finish_line,(150 - (i*square_size*2)))
turtle.stamp()
turtle.hideturtle()
# turtles
t1 = Turtle()
t1.speed(0)
t1.color('blue')
t1.shape('turtle')
t1.penup()
t1.goto(-250,100)
t1.pendown()
# 2nd
t2 = Turtle()
t2.speed(0)
t2.color('green')
t2.shape('turtle')
t2.penup()
t2.goto(-250,50)
t2.pendown()
#3rd
t3 = Turtle()
t3.speed(0)
t3.color('orange')
t3.shape('turtle')
t3.penup()
t3.goto(-250,0)
t3.pendown()
#4th
t4 = Turtle()
t4.speed(0)
t4.color('red')
t4.shape('turtle')
t4.penup()
t4.goto(-250,-50)
t4.pendown()
time.sleep(1)
# start the race
for i in range(145):
t1.forward(randint(1,5))
t2.forward(randint(1, 5))
t3.forward(randint(1, 5))
t4.forward(randint(1, 5))
turtle.exitonclick()
turtle.Screen().mainloop()
turtle.done()