day 20 - fixed collision issues

This commit is contained in:
Tanguy Deleplanque
2025-07-15 15:13:04 +02:00
parent df22e55f4b
commit 6857990be5
3 changed files with 15 additions and 13 deletions

View File

@ -39,11 +39,9 @@ class GameManager:
return wall_collision or snake_collision
def is_food_eaten(self):
snake_x, snake_y = self.snake.get_head_position()
food_x, food_y = self.food.get_position()
snake_head = self.snake.get_head()
if int(snake_x) == int(food_x) and int(snake_y) == int(food_y):
print("Yihaa")
if snake_head.distance(self.food) <= 15:
self.food.hide()
self.snake.extend()
self.food_on_screen = False