-
Notifications
You must be signed in to change notification settings - Fork 0
/
turtle_game.py
74 lines (52 loc) · 1.05 KB
/
turtle_game.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
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
from turtle import *
from random import randint
screen = Screen()
screen.setup(820,520)
screen.bgcolor('black')
color('white')
speed(0)
penup() #remove the drawing of the pen
goto(-140, 140) #the turtle starts at the middle of the screen(0, 0)
for step in range(16):
write(step, align='center')
right(90)
forward(10)
pendown()
forward(150)
penup()
backward(160)
left(90)
forward(20)
#Adding 1st turtle
ada = Turtle()
ada.color('red')
ada.shape('turtle')
ada.penup()
ada.goto(-160, 100)
ada.pendown()
#Adding 2nd turtle
bob = Turtle()
bob.color('blue')
bob.shape('turtle')
bob.penup()
bob.goto(-160, 70)
bob.pendown()
#Adding 3rd turtle
viv = Turtle()
viv.color('green')
viv.shape('turtle')
viv.penup()
viv.goto(-160, 40)
viv.pendown()
#Adding 4th turtle
art = Turtle()
art.color('yellow')
art.shape('turtle')
art.penup()
art.goto(-160, 10)
art.pendown()
for turn in range(100):
ada.forward(randint(1,5))
bob.forward(randint(1,5))
viv.forward(randint(1,5))
art.forward(randint(1,5))