generated from mwc/project_game
I'm proud of making the circles fall from the top one at a time. I was stuck on making the circle fall.
27 lines
788 B
Python
27 lines
788 B
Python
from random import randint
|
|
class Circle:
|
|
name= "circle"
|
|
character = 'O'
|
|
|
|
def __init__(self, position):
|
|
self.position = position
|
|
|
|
def play_turn(self, game):
|
|
width, height = game.board_size
|
|
fall_speed = game.state.get("fall_speed", 1)
|
|
|
|
x, y = self.position
|
|
player = game.get_agent_by_name('player')
|
|
new_position = (x, y + 1)
|
|
|
|
if new_position == player.position:
|
|
game.end()
|
|
return
|
|
if y >= height - 1:
|
|
game.state["score"] += 1
|
|
if game.state["fall_speed"] < 5:
|
|
game.state["fall_speed"] += 1
|
|
self.position = (randint(0, width - 1), 0)
|
|
else:
|
|
self.position = new_position
|