MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / start_game

Function start_game

Caterpillar_Game/Caterpillar.py:81–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79 leaf.showturtle()
80
81def start_game():
82 global game_started
83 if game_started:
84 return
85 game_started = True
86
87 score = 0
88 text_turtle.clear()
89
90 caterpillar_speed = 2
91 caterpillar_length = 3
92 caterpillar.shapesize(1,caterpillar_length,1)
93 caterpillar.showturtle()
94 display_score(score)
95 place_leaf()
96
97 while True:
98 caterpillar.forward(caterpillar_speed)
99 for obstacle in obstacles:
100 if caterpillar.distance(leaf) < 20:
101 place_leaf()
102 caterpillar_length = caterpillar_length + 1
103 caterpillar.shapesize(1,caterpillar_length,1)
104 caterpillar_speed = caterpillar_speed + 1
105 score = score + 10
106 display_score(score)
107 game_over()
108 break
109 if outside_window():
110 game_over()
111 break
112
113
114def move_up():

Callers 1

restart_gameFunction · 0.70

Calls 4

display_scoreFunction · 0.85
place_leafFunction · 0.85
game_overFunction · 0.85
outside_windowFunction · 0.85

Tested by

no test coverage detected