diff options
-rw-r--r-- | brutalmaze/characters.py | 30 | ||||
-rw-r--r-- | brutalmaze/maze.py | 8 | ||||
-rwxr-xr-x | setup.py | 2 |
3 files changed, 30 insertions, 10 deletions
diff --git a/brutalmaze/characters.py b/brutalmaze/characters.py index 752ea21..ac681c5 100644 --- a/brutalmaze/characters.py +++ b/brutalmaze/characters.py @@ -176,7 +176,7 @@ class Enemy: atan2(self.maze.y - y, self.maze.x - x), self.color)) return True - def move(self): + def move(self, speed=ENEMY_SPEED): """Return True if it has just moved, False otherwise.""" if self.offsetx: self.offsetx -= sign(self.offsetx) @@ -186,7 +186,7 @@ class Enemy: return True if self.next_strike > pygame.time.get_ticks(): return False - self.move_speed = self.maze.fps / ENEMY_SPEED + self.move_speed = self.maze.fps / speed directions = [(sign(MIDDLE - self.x), 0), (0, sign(MIDDLE - self.y))] shuffle(directions) directions.append(choice(CROSS)) @@ -199,6 +199,14 @@ class Enemy: return True return False + def slash(self): + """Handle the enemy's close-range attack.""" + if not self.spin_queue: return + x, y = self.pos() + d = self.maze.slashd - self.maze.length(x, y) + if d >= 0: + self.maze.hit(d / self.maze.hero.R / self.spin_speed, self.color) + def draw(self): """Draw the enemy.""" radious = self.maze.distance/SQRT2 - self.awake*2 @@ -295,6 +303,24 @@ class ScarletRed(Enemy): def __init__(self, maze, x, y): Enemy.__init__(self, maze, x, y, 'ScarletRed') + def fire(self): + """Scarlet Red doesn't shoot.""" + return False + + def move(self): + return Enemy.move(self, ENEMY_SPEED * SQRT2) + + def slash(self): + """Handle the Scarlet Red's close-range attack.""" + if not self.spin_queue: return + x, y = self.pos() + d = self.maze.slashd - self.maze.length(x, y) + wound = d / self.maze.hero.R / self.spin_speed + if wound >= 0: + self.maze.hit(wound, self.color) + self.wound -= wound + if self.wound < 0: self.wound = 0.0 + def new_enemy(maze, x, y): """Return an enemy of a random type in the grid (x, y).""" diff --git a/brutalmaze/maze.py b/brutalmaze/maze.py index c7c7102..cf22438 100644 --- a/brutalmaze/maze.py +++ b/brutalmaze/maze.py @@ -185,13 +185,7 @@ class Maze: def slash(self): """Handle close-range attacks.""" - for enemy in self.enemies: - if not enemy.spin_queue: continue - x, y = enemy.pos() - d = self.slashd - self.length(x, y) - if d >= 0: - self.hit(d / self.hero.R / enemy.spin_speed, enemy.color) - + for enemy in self.enemies: enemy.slash() if not self.hero.spin_queue: return unit, killist = self.distance/SQRT2 * self.hero.spin_speed, [] for i, enemy in enumerate(self.enemies): diff --git a/setup.py b/setup.py index 24b057d..c3084c5 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open('README.rst') as f: setup( name='brutalmaze', - version='0.1.0', + version='0.1.1', description='A hash and slash game with fast-paced action and a minimalist art style', long_description=long_description, url='https://github.com/McSinyx/brutalmaze', |