Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
Fix zombie enemies and heart rate
Browse files Browse the repository at this point in the history
  • Loading branch information
McSinyx committed Jul 24, 2019
1 parent 4f18daa commit 622df8c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
4 changes: 3 additions & 1 deletion brutalmaze/characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class Enemy:
x, y (int): coordinates of the center of the enemy (in grids)
angle (float): angle of the direction the enemy pointing (in radians)
color (str): enemy's color name
alive (bool): flag indicating if the enemy is alive
awake (bool): flag indicating if the enemy is active
next_strike (float): time until the enemy's next action (in ms)
move_speed (float): speed of movement (in frames per grid)
Expand All @@ -175,7 +176,7 @@ def __init__(self, maze, x, y, color):
self.x, self.y = x, y
self.angle, self.color = pi / 4, color

self.awake = False
self.alive, self.awake = True, False
self.next_strike = 0.0
self.move_speed = self.maze.fps / ENEMY_SPEED
self.offsetx = self.offsety = 0
Expand Down Expand Up @@ -354,6 +355,7 @@ def die(self):
self.maze.enemy_weights[self.color] -= 1.5
else:
self.maze.map[self.x][self.y] = WALL
self.alive = False


class Chameleon(Enemy):
Expand Down
2 changes: 1 addition & 1 deletion brutalmaze/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
MINW, MAXW = 24, 36
ENEMY_HP = 3
HERO_HP = 5
MIN_BEAT = 526
MIN_BEAT = 420
BG_COLOR = TANGO['Aluminium'][-1]
FG_COLOR = TANGO['Aluminium'][0]

Expand Down
2 changes: 1 addition & 1 deletion brutalmaze/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with Brutal Maze. If not, see <https://www.gnu.org/licenses/>.

__version__ = '0.8.25'
__version__ = '0.8.26'

import re
from argparse import ArgumentParser, FileType, RawTextHelpFormatter
Expand Down
13 changes: 4 additions & 9 deletions brutalmaze/maze.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def draw_bit(bit, dx=0, dy=0):

def add_enemy(self):
"""Add enough enemies."""
self.enemies = [e for e in self.enemies if e.alive]
walls = [(i, j) for i in self.rangex for j in self.rangey
if self.map[i][j] == WALL]
plums = [e for e in self.enemies if e.color == 'Plum' and e.awake]
Expand Down Expand Up @@ -223,14 +224,11 @@ def rotate(self):
self.stepx = self.stepy = 0

# Respawn the enemies that fall off the display
killist = []
for i, enemy in enumerate(self.enemies):
enemy.place(x, y)
if not self.isdisplayed(enemy.x, enemy.y):
self.score += enemy.wound
enemy.die()
killist.append(i)
for i in reversed(killist): self.enemies.pop(i)
self.add_enemy()

# LockOn target is not yet updated.
Expand Down Expand Up @@ -281,8 +279,7 @@ def slash(self):
"""Handle close-range attacks."""
for enemy in self.enemies: enemy.slash()
if not self.hero.spin_queue: return
killist = []
for i, enemy in enumerate(self.enemies):
for enemy in filter(lambda e: e.awake, self.enemies):
d = self.slashd - enemy.distance
if d > 0:
wound = d * SQRT2 / self.distance
Expand All @@ -293,8 +290,6 @@ def slash(self):
if enemy.wound >= ENEMY_HP:
self.score += enemy.wound
enemy.die()
killist.append(i)
for i in reversed(killist): self.enemies.pop(i)
self.add_enemy()

def track_bullets(self):
Expand Down Expand Up @@ -323,13 +318,13 @@ def track_bullets(self):
enemy.hit(wound)
self.enemies.append(enemy)
continue
for j, enemy in enumerate(active_enemies):
for enemy in active_enemies:
if bullet.get_distance(*enemy.pos) < self.distance:
enemy.hit(wound)
if enemy.wound >= ENEMY_HP:
self.score += enemy.wound
enemy.die()
self.enemies.pop(j)
self.add_enemy()
play(bullet.sfx_hit, wound, bullet.angle)
fallen.append(i)
break
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='brutalmaze',
version='0.8.25',
version='0.8.26',
description="Minimalist thrilling shoot 'em up game",
long_description=long_description,
url='https://github.com/McSinyx/brutalmaze',
Expand Down

0 comments on commit 622df8c

Please sign in to comment.