generated from mwc/project_game
Im thinking i might change the kind of game i want to build to a shooting the aliens and asteroid but i need to figure out how to make the ship shoot and what happens when something hits it.
19 lines
586 B
Python
19 lines
586 B
Python
class Asteroid:
|
|
character = 'O'
|
|
|
|
def __init__(self, position):
|
|
self.position = position
|
|
|
|
def play_turn(self, game):
|
|
width, height = game.board_size
|
|
if game.turn_number % 2 == 0:
|
|
x, y = self.position
|
|
if y == height - 1:
|
|
game.remove_agent(self)
|
|
else:
|
|
ship = game.get_agent_by_name('ship')
|
|
new_position = (x, y + 1)
|
|
if new_position == ship.position:
|
|
game.end()
|
|
else:
|
|
self.position = new_position |