Conteúdo do Curso
Building a Classic Snake Game
Swipe to show menu
Handling Collisions
Calling game over
We did all the hard work before when created is_body_collision()
method, so now we just have to use it. First of all let's ensure that there is a game_over()
when the snake head collides with its body.
Collision with fruit
Let's consider what should occur when the snake's head collides with a fruit. Naturally, when this happens, the fruit needs to appear in a different location, and the snake's length should increase. This concept is straightforward to understand and also implement:
The code snippet above detects if the snake collides with a fruit. Upon collision, the fruit moves to a new position, the snake grows longer.
Tarefa
Swipe to show code editor
- Add and implement handle_collision method.
- Add collision detection for Game Over.
- Add collision detection with Fruit.
Solução
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?
Obrigado pelo seu feedback!
Seção 1. Capítulo 10
AVAILABLE TO ULTIMATE ONLY