generated from mwc/project_game
added a monster spawner and modified lvl mechanics
Monsters have a weighting on how many to spawn and roll which specific monster to spawn from the pool. I have not added the ability to advance levels yet, though that should work to add monsters if the Floor number advances. I did notice a bug where the player cannot be harmed by the monsters unless the player moves into them, not the other way around. The monsters seem to treat the player as a wall that cannot be passed through. This is confusing because the code for the player and monsters match as far as their ability to move into each other...
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
# projectile.py
|
||||
# ------------
|
||||
# By Pat Wick
|
||||
# This module defines a "casted" projectile. This is the basis
|
||||
# for ranged character types' attacks.
|
||||
|
||||
from retro.game import Game
|
||||
|
||||
class Projectile:
|
||||
@@ -13,10 +19,18 @@ class Projectile:
|
||||
self.character = "-"
|
||||
elif self.direction in [(0,1), (0,-1)]:
|
||||
self.character = "|"
|
||||
if game.get_agent_by_name("player").class_ == "Warrior":
|
||||
if self.direction in [(0,1), (0,-1)]:
|
||||
self.character = "|"
|
||||
elif self.direction == (1,0):
|
||||
self.character = "/"
|
||||
else:
|
||||
self.character = "\\"
|
||||
|
||||
def move(self, game):
|
||||
"""Try to move in direction set by player when launched. If blocked,
|
||||
disappear."""
|
||||
disappear. If projectile hits an enemy, lower hp by damage.
|
||||
"""
|
||||
dx, dy = self.direction
|
||||
new_position = (self.position[0] + dx, self.position[1] + dy)
|
||||
if game.on_board(new_position):
|
||||
@@ -34,8 +48,16 @@ class Projectile:
|
||||
game.remove_agent(self)
|
||||
|
||||
def play_turn(self,game):
|
||||
"""Speed of projectiles depends on character race.
|
||||
"""
|
||||
if game.turn_number % self.speed == 0:
|
||||
self.move(game)
|
||||
try:
|
||||
if game.get_agent_by_name("player").class_ == "Warrior":
|
||||
game.remove_agent(self)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def get_agent_in_position(self, position, game):
|
||||
"""Returns an agent at the position, or returns None.
|
||||
|
||||
Reference in New Issue
Block a user