generated from mwc/project_game
Im proud im understanding what im doing
Im stuck on testing my code Im worried my code isnt doing what i want it to but i cant test it to see
This commit is contained in:
19
obstacle.py
Normal file
19
obstacle.py
Normal file
@@ -0,0 +1,19 @@
|
||||
class Obstacle:
|
||||
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:
|
||||
froggy = game.get_agent_by_name('froggy')
|
||||
new_position = (x, y + 1)
|
||||
if new_position == froggy.position:
|
||||
game.end()
|
||||
else:
|
||||
self.position = new_position
|
||||
Reference in New Issue
Block a user