summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-01-26 22:50:52 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-01-28 09:06:28 +0700
commitf9e4ab3ef1fd45d71357319ff2abe3020302ab5c (patch)
tree174db50358f32dcba452d572650ccc4ef88e8759
parentb4c900ec0df7badf66caa02b0e6456e66c022ba7 (diff)
downloadbrutalmaze-f9e4ab3ef1fd45d71357319ff2abe3020302ab5c.tar.gz
Fix spawn sound volume
-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',