Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Losing Condition | Building a Classic Snake Game
Building a Classic Snake Game
course content

Conteúdo do Curso

Building a Classic Snake Game

Losing Condition

Game Over

When the snake collides with its own body or any other obstacle, it signals the end of the game. The game_over() method is invoked to conclude the current game session. To implement this we will simply use our running attribute and set it to false and then reset the game.

Resetting the Game

After the game ends it's essential to reset the game state for another round. The reset() method restores the game's initial conditions and prepares it for a fresh start:

copy

Note

Basically, we just stick with the default values provided in the __init__() functions of the game, snake, and fruit classes.

Tarefa

  • Add and implement reset() method to the game.
  • Add and implement game_over() method to the game class.

Tarefa

  • Add and implement reset() method to the game.
  • Add and implement game_over() method to the game class.

Mark tasks as Completed
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Game Over

When the snake collides with its own body or any other obstacle, it signals the end of the game. The game_over() method is invoked to conclude the current game session. To implement this we will simply use our running attribute and set it to false and then reset the game.

Resetting the Game

After the game ends it's essential to reset the game state for another round. The reset() method restores the game's initial conditions and prepares it for a fresh start:

copy

Note

Basically, we just stick with the default values provided in the __init__() functions of the game, snake, and fruit classes.

Tarefa

  • Add and implement reset() method to the game.
  • Add and implement game_over() method to the game class.

Mark tasks as Completed
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 1. Capítulo 9
AVAILABLE TO ULTIMATE ONLY
We're sorry to hear that something went wrong. What happened?
some-alt