Files
project_game/food.py
2025-12-14 00:51:52 -05:00

19 lines
440 B
Python

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()