MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / game_loop

Method game_loop

projects/Snake Game/src/game.py:20–35  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

18 self.high_score = self.load_high_score()
19
20 def game_loop(self):
21 while True:
22 self.play_step()
23 game_over, score = self.play_step()
24 self.update_high_score(self.high_score)
25 if game_over:
26 self.display.render_game_over()
27 if score > self.high_score:
28 self.display.render_new_high_score(score)
29 self.update_high_score(score)
30 self.high_score = self.load_high_score()
31 self.display.render_play_again()
32 if not self.play_again():
33 break
34 self.restart_game()
35 pygame.quit()
36
37 def is_collision(self):
38 """Checks if the snake has collided with the boundary or with itself.

Callers 1

main.pyFile · 0.45

Calls 8

play_stepMethod · 0.95
update_high_scoreMethod · 0.95
load_high_scoreMethod · 0.95
play_againMethod · 0.95
restart_gameMethod · 0.95
render_game_overMethod · 0.80
render_new_high_scoreMethod · 0.80
render_play_againMethod · 0.80

Tested by

no test coverage detected