generated from mwc/project_game
Fixing game to working state
This commit is contained in:
18
fruit_catcher/manager.py
Normal file
18
fruit_catcher/manager.py
Normal file
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user