about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-01-22 23:29:22 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-01-22 23:34:40 +0700
commitd88db7fc051365c0126f65ae119b72486bbf2712 (patch)
treeecbcbc77ee13b05234c912728c359e8cec7ac82b
parent7839f30240b4e9e0469058d40f0276dc3e6a2c19 (diff)
downloadbrutalmaze-d88db7fc051365c0126f65ae119b72486bbf2712.tar.gz
Add disturbing heart beat and give clue of all attacks 0.3.2
-rw-r--r--brutalmaze/characters.py13
-rw-r--r--brutalmaze/constants.py2
-rw-r--r--brutalmaze/soundfx/heart.oggbin0 -> 8385 bytes
-rwxr-xr-xsetup.py2
4 files changed, 14 insertions, 3 deletions
diff --git a/brutalmaze/characters.py b/brutalmaze/characters.py
index 395514a..0ffcd95 100644
--- a/brutalmaze/characters.py
+++ b/brutalmaze/characters.py
@@ -41,6 +41,7 @@ class Hero:
         color (tuple of pygame.Color): colors of the hero on different HPs
         R (int): circumradius of the regular triangle representing the hero
         next_heal (int): the tick that the hero gains back healing ability
+        next_beat (int): the tick to play next heart beat
         next_strike (int): the tick that the hero can do the next attack
         slashing (bool): flag indicates if the hero is doing close-range attack
         firing (bool): flag indicates if the hero is doing long-range attack
@@ -48,6 +49,7 @@ class Hero:
         spin_speed (float): speed of spinning (in frames per slash)
         spin_queue (float): frames left to finish spinning
         wound (float): amount of wound
+        sfx_heart (Sound): heart beat sound effect
     """
     def __init__(self, surface, fps):
         self.surface = surface
@@ -56,11 +58,13 @@ class Hero:
         self.angle, self.color = pi / 4, TANGO['Aluminium']
         self.R = (w * h / sin(pi*2/3) / 624) ** 0.5
 
-        self.next_heal = self.next_strike = 0
+        self.next_heal = self.next_beat = self.next_strike = 0
         self.slashing = self.firing = self.dead = False
         self.spin_speed = fps / HERO_HP
         self.spin_queue = self.wound = 0.0
 
+        self.sfx_heart = pygame.mixer.Sound(SFX_HEART)
+
     def update(self, fps):
         """Update the hero."""
         if self.dead:
@@ -72,6 +76,10 @@ class Hero:
         if time > self.next_heal:
             self.wound -= HEAL_SPEED / self.spin_speed / HERO_HP
             if self.wound < 0: self.wound = 0.0
+        if time > self.next_beat:
+            wound = self.wound / HERO_HP
+            play(self.sfx_heart, wound ** 0.5)
+            self.next_beat = time + MIN_BEAT*(2-wound)
 
         if self.slashing and time >= self.next_strike:
             self.next_strike = time + ATTACK_SPEED
@@ -264,7 +272,8 @@ class Chameleon(Enemy):
 
     def draw(self):
         """Draw the Chameleon."""
-        if not self.awake or pygame.time.get_ticks() <= self.visible:
+        if (not self.awake or self.spin_queue
+            or pygame.time.get_ticks() <= self.visible):
             Enemy.draw(self)
 
     def hit(self, wound):
diff --git a/brutalmaze/constants.py b/brutalmaze/constants.py
index 2f756e6..5e96922 100644
--- a/brutalmaze/constants.py
+++ b/brutalmaze/constants.py
@@ -30,6 +30,7 @@ SFX_SLASH_HERO = resource_filename('brutalmaze', 'soundfx/slash-hero.ogg')
 SFX_SHOT_ENEMY = resource_filename('brutalmaze', 'soundfx/shot-enemy.ogg')
 SFX_SHOT_HERO = resource_filename('brutalmaze', 'soundfx/shot-hero.ogg')
 SFX_MISSED = resource_filename('brutalmaze', 'soundfx/missed.ogg')
+SFX_HEART = resource_filename('brutalmaze', 'soundfx/heart.ogg')
 SFX_LOSE = resource_filename('brutalmaze', 'soundfx/lose.ogg')
 
 UP = (K_UP, K_w)
@@ -73,5 +74,6 @@ ENEMIES = ['Butter', 'Orange', 'Chocolate', 'Chameleon',
 MINW, MAXW = 24, 36
 ENEMY_HP = 3
 HERO_HP = 5
+MIN_BEAT = 526
 BG_COLOR = TANGO['Aluminium'][-1]
 FG_COLOR = TANGO['Aluminium'][0]
diff --git a/brutalmaze/soundfx/heart.ogg b/brutalmaze/soundfx/heart.ogg
new file mode 100644
index 0000000..89c61af
--- /dev/null
+++ b/brutalmaze/soundfx/heart.ogg
Binary files differdiff --git a/setup.py b/setup.py
index 83f781a..fb11231 100755
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ with open('README.rst') as f:
 
 setup(
     name='brutalmaze',
-    version='0.3.1',
+    version='0.3.2',
     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',