This round, i was able to add the food and set up the collisions but after i edited some parts, the game just started crashing everytime.

It worked up until I got to test to take away the food and add it.
This commit is contained in:
mbhatti4
2025-12-14 00:51:52 -05:00
parent e273f1a954
commit cf49d4e0e4
5 changed files with 60 additions and 27 deletions

18
food.py Normal file
View File

@@ -0,0 +1,18 @@
import random
class Food:
name = "food"
character = "*"
def __init__(self, board_size):
self.board_width, self.board_height = board_size
self.position = self._random_position()
def _random_position(self):
x = random.randint(0, self.board_width - 1)
y = random.randint(0, self.board_height - 1)
return (x, y)
def respawn(self):
self.position = self._random_position()