Files
project_game/obstacle.py
mollychi 4f3655867f 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
2025-12-05 19:50:01 -05:00

20 lines
593 B
Python

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