project_game/trap.py

39 lines
1005 B
Python

class Trap:
character = ''
color = 'black'
passable = True
@classmethod
def trap(cls, origin, height):
agents = []
x, y = origin
for dx in range(height):
trap = Trap((x + dx, y))
agents.append(trap)
return agents
def __init__(self, position, lives, message):
self.position = position
self.lives = lives
self.message = message
def collided_with_player(self, player, game):
game.state["lives"] -= 1
game.remove_agent(self)
player.color = "red_on_salmon"
game.state['message'] = self.message
if game.state["lives"] <= 0:
game.state['message'] = "You Lost the Game! Play Again."
game.end()
"""Want to use
character = ''
color = 'red'
when Player hits"""
"""Code if the Player hits the Trap,
the 1 Die is added to the current total Dies"""
"""Game ends if the Player Scores 60 points or 3 deaths"""