Asks the user to play again or quit the game.
(self)
| 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.""" |
no outgoing calls