checking in

I can't quite get the game to work. It keeps crashing when the
asteroid gets to the bottom.
This commit is contained in:
Chris Mekelburg
2024-11-27 21:52:10 -05:00
parent d724c1ddbb
commit ff2cd961d3
9 changed files with 79 additions and 0 deletions

View File

@@ -2,3 +2,22 @@
# ------------
# By MWC Contributors
# This module defines an asteroid agent class.
class Asteroid:
character = '0'
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: #need to rename as height
game.remove_agent_by_name(name.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