Files
project_game/manager.py

18 lines
480 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, 26)
fruit = Fruit((x, 1), game, choice(SHAPE_DEFINITIONS))
game.add_agent(fruit)