You have to keep testing it and go back and forth to the code

This commit is contained in:
mdecker6
2025-11-10 12:44:09 -05:00
parent d9cf11291a
commit 34ece06307
7 changed files with 73 additions and 8 deletions

View File

@@ -2,3 +2,21 @@
# ------------
# 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 == HEIGHT - 1:
game.remove_agent_by_name(self.name)
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