generated from mwc/lab_retro
finished the game
The program in unit 1, the turtle would draw whatever you made when it starts, but for the nav_game the objects are already made, and you can move things around after it starts
This commit is contained in:
21
asteroid.py
21
asteroid.py
@@ -2,3 +2,24 @@
|
||||
# ------------
|
||||
# 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):
|
||||
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
|
||||
Reference in New Issue
Block a user