about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-rw-r--r--brutalmaze/characters.py12
-rw-r--r--brutalmaze/maze.py2
-rwxr-xr-xsetup.py2
3 files changed, 11 insertions, 5 deletions
diff --git a/brutalmaze/characters.py b/brutalmaze/characters.py
index d28ea0b..c47e22e 100644
--- a/brutalmaze/characters.py
+++ b/brutalmaze/characters.py
@@ -141,6 +141,12 @@ class Enemy:
         step = self.maze.distance * HERO_SPEED / self.maze.fps
         return x + self.offsetx*step, y + self.offsety*step
 
+    def get_distance(self):
+        """Return the distance from the center of the enemy to
+        the center of the maze.
+        """
+        return self.maze.get_distance(*self.get_pos())
+
     def place(self, x=0, y=0):
         """Move the enemy by (x, y) (in grids)."""
         self.x += x
@@ -169,7 +175,8 @@ class Enemy:
                 if get_distance(x - self.maze.x, y - self.maze.y) <= mind:
                     return False
         self.awake = True
-        play(self.maze.sfx_spawn, self.maze.get_distance(*self.get_pos()),
+        play(self.maze.sfx_spawn,
+             1 - self.get_distance()/self.maze.get_distance(0, 0)/2,
              self.get_angle() + pi)
         return True
 
@@ -213,8 +220,7 @@ class Enemy:
 
     def get_slash(self):
         """Return the enemy's close-range damage."""
-        d = self.maze.slashd - self.maze.get_distance(*self.get_pos())
-        wound = d / self.maze.hero.R
+        wound = (self.maze.slashd - self.get_distance()) / self.maze.hero.R
         return wound if wound > 0 else 0.0
 
     def slash(self):
diff --git a/brutalmaze/maze.py b/brutalmaze/maze.py
index 2123a74..86edadf 100644
--- a/brutalmaze/maze.py
+++ b/brutalmaze/maze.py
@@ -220,7 +220,7 @@ class Maze:
         if not self.hero.spin_queue: return
         killist = []
         for i, enemy in enumerate(self.enemies):
-            d = self.slashd - self.get_distance(*enemy.get_pos())
+            d = self.slashd - enemy.get_distance()
             if d > 0:
                 wound, time = d * SQRT2 / self.distance, get_ticks()
                 if time >= self.next_slashfx:
diff --git a/setup.py b/setup.py
index 8630a56..19ba02b 100755
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ with open('README.rst') as f:
 
 setup(
     name='brutalmaze',
-    version='0.4.0',
+    version='0.4.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',