Completed retro lab.

This commit is contained in:
Danielle Tear
2024-02-21 15:08:18 -05:00
parent d92c745dac
commit dfe8593794
7 changed files with 73 additions and 0 deletions

View File

@@ -2,3 +2,22 @@
# ------------
# By MWC Contributors
# This module defines an asteroid agent class.
class Asteroid:
character = 'O'
def __init__(self, position):
self.position = position
def play_turn(self, game):
if game.turn_number % 2 == 0:
x, y = self.position
if y == 25 - 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