Files
project_game/fruit_catcher/manager.py
2026-03-19 12:15:22 -04:00

19 lines
482 B
Python

from .fruit import Fruit, SHAPE_DEFINITIONS
from random import choice, randint
from retro.errors import AgentNotFoundByName
class FruitManager:
display = False
def play_turn(self, game):
try:
game.get_agent_by_name("fruit")
except AgentNotFoundByName:
self.create_piece(game)
def create_piece(self, game):
x = randint(0, 25)
fruit = Fruit((x, 1), game, choice(SHAPE_DEFINITIONS))
game.add_agent(fruit)