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

Method play_again

projects/Snake Game/src/game.py:111–121  ·  view source on GitHub ↗

Asks the user to play again or quit the game.

(self)

Source from the content-addressed store, hash-verified

109 self.place_food()
110
111 def play_again(self):
112 """Asks the user to play again or quit the game."""
113 while True:
114 for event in pygame.event.get():
115 if event.type == pygame.QUIT:
116 return False
117 if event.type == pygame.KEYDOWN:
118 if event.key in [pygame.K_n, pygame.K_ESCAPE]:
119 return False
120 if event.key in [pygame.K_y, pygame.K_RETURN]:
121 return True
122
123 def restart_game(self):
124 """Resets the state of the game."""

Callers 3

game_loopMethod · 0.95
test_play_again_yMethod · 0.80

Calls

no outgoing calls

Tested by 2

test_play_again_yMethod · 0.64