I didnt understand this well, I kind of understood how you did it, but most of it is confusing because I. Did. Not. Learn. ANY. OF. THIS.

This commit is contained in:
jbayati
2025-11-18 09:33:55 -05:00
parent ffe1993926
commit 3a2fdf30f0
7 changed files with 65 additions and 0 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