sound effects
authorFrank DeMarco <frank.s.demarco@gmail.com>
Sat, 31 May 2014 08:11:28 +0000 (17:11 +0900)
committerFrank DeMarco <frank.s.demarco@gmail.com>
Sat, 31 May 2014 08:11:28 +0000 (17:11 +0900)
16 files changed:
config
lake_of_heavenly_wind/LakeOfHeavenlyWind.py
resource/aud/Knife-Glory/9i.ogg [deleted file]
resource/aud/Knife-Glory/Mb.ogg [deleted file]
resource/aud/Knife-Glory/No.ogg [deleted file]
resource/aud/Knife-Glory/O0.ogg [deleted file]
resource/aud/Knife-Glory/detonate-4.ogg [new file with mode: 0644]
resource/aud/Knife-Glory/drop-1.ogg [new file with mode: 0644]
resource/aud/Knife-Glory/eE.ogg [deleted file]
resource/aud/Knife-Glory/eliminate-2.ogg [new file with mode: 0644]
resource/aud/Knife-Glory/lose-health.ogg [new file with mode: 0644]
resource/aud/Knife-Glory/no.ogg [deleted file]
resource/aud/Knife-Glory/power-up.ogg [new file with mode: 0644]
resource/aud/Knife-Glory/start.ogg [new file with mode: 0644]
resource/aud/Knife-Glory/ww.ogg [deleted file]
resource/high-scores

diff --git a/config b/config
index f606f1c..54d20cc 100644 (file)
--- a/config
+++ b/config
@@ -30,7 +30,13 @@ paddle = img/Old-Bag-of-Bones.png
 pulp = img/Burns-1930/
 
 [audio]
-fx = aud/Knife-Glory/
+detonate = aud/Knife-Glory/detonate-4.ogg
+drop = aud/Knife-Glory/drop-1.ogg
+eliminate = aud/Knife-Glory/eliminate-2.ogg
+power-up = aud/Knife-Glory/power-up.ogg
+lose-health = aud/Knife-Glory/01.ogg
+blow-up = aud/Knife-Glory/lose-health.ogg
+start = aud/Knife-Glory/start.ogg
 outer = aud/Fever-for-Immolation-Ruins.ogg
 inner = aud/Sunpeak-Capsaicin.ogg
 
index 80add0a..97cacbe 100644 (file)
@@ -11,6 +11,7 @@ from pygame.image import load, save
 from pygame.draw import circle, arc, aaline, line, ellipse
 from pygame.font import Font
 from pygame.mixer import Sound
+from pygame.event import clear
 from pygame.locals import *
 
 from lake_of_heavenly_wind.pgfw.Game import Game
@@ -132,6 +133,7 @@ class Title(GameChild):
         self.display_surface = self.get_display_surface()
         self.delegate = self.get_game().delegate
         self.music = Sound(self.get_resource("audio", "outer"))
+        self.start_fx = SoundEffect(self, "start", .5)
         self.deactivate()
         background = self.background = Sprite(self)
         tile_size = self.tile_size = 8
@@ -174,7 +176,7 @@ class Title(GameChild):
         font = Font(self.get_resource("display", "font"), 12)
         color = Color(0, 0, 0)
         if random() < .92:
-            texts = ["Wind from Heaven's Lake", u"澤 天 風"]
+            texts = ["Wind Off of Heaven's Lake", u"澤 天 風"]
         else:
             texts = ["Pleasure in Strong Penetration", u"兌 乾 巽"]
         for text in texts:
@@ -199,6 +201,7 @@ class Title(GameChild):
             if self.delegate.compare(event, "any"):
                 self.deactivate()
                 self.parent.game_screen.activate()
+                self.start_fx.play()
 
     def activate(self, incoming=None):
         self.active = True
@@ -222,6 +225,7 @@ class Title(GameChild):
                                                        count / 2.0 + .5)
             scores.append(sprite)
         self.set_caption()
+        clear()
 
     def update(self):
         if self.active:
@@ -248,10 +252,17 @@ class Title(GameChild):
 
 class SoundEffect(GameChild, Sound):
 
-    def __init__(self, parent, name):
+    def __init__(self, parent, name, volume=1.0):
         GameChild.__init__(self, parent)
-        Sound.__init__(self, join(self.get_resource("audio", "fx"),
-                                  name + ".ogg"))
+        Sound.__init__(self, self.get_resource("audio", name))
+        self.name = name
+        self.set_volume(volume)
+
+    def play(self, position=.5):
+        channel = Sound.play(self)
+        right = 1 + min(0, ((position - .5) * 2))
+        left = 1 - max(0, ((position - .5) * 2))
+        channel.set_volume(left, right)
 
 
 class GameScreen(GameChild):
@@ -272,6 +283,7 @@ class GameScreen(GameChild):
         self.time_filter = self.get_game().time_filter
         self.display_surface = self.get_display_surface()
         self.music = Sound(self.get_resource("audio", "inner"))
+        self.music.set_volume(.8)
         self.previous_palette = None
         self.wave = 0
         self.deactivate()
@@ -411,7 +423,8 @@ class Pulp(GameChild, Surface):
         self.display_surface = self.get_display_surface()
         self.font = Font(self.get_resource("display", "font"), 24)
         self.explosions = [Explosion(self) for _ in xrange(32)]
-        self.lose_health_fx = SoundEffect(self, "No")
+        self.lose_health_fx = SoundEffect(self, "lose-health")
+        self.blow_up_fx = SoundEffect(self, "blow-up", .8)
         self.reset()
         Surface.__init__(self, (self.display_surface.get_width(), 96))
         self.rect = self.get_rect()
@@ -496,9 +509,14 @@ class Pulp(GameChild, Surface):
                     self.parent.end()
                     break
         if outgoing:
-            self.lose_health_fx.play()
-        for phage in outgoing:
-            self.parent.rails.phages.remove(phage)
+            total = 0
+            for phage in outgoing:
+                total += phage.get_center()[0]
+                self.parent.rails.phages.remove(phage)
+            position = float(total) / len(outgoing) / \
+                       self.get_display_surface().get_width()
+            self.lose_health_fx.play(position)
+            self.blow_up_fx.play(position)
         for explosion in self.explosions:
             explosion.update()
 
@@ -577,9 +595,9 @@ class Paddles(GameChild):
         self.time_filter = self.get_game().time_filter
         self.display_surface = self.get_display_surface()
         self.delegate = self.get_game().delegate
-        self.detonate_mine_fx = SoundEffect(self, "ww")
-        self.drop_mine_fx = SoundEffect(self, "ww")
-        # self.eliminate_phage_fx = SoundEffect(self, "Mb")
+        self.detonate_mine_fx = SoundEffect(self, "detonate", .8)
+        self.drop_mine_fx = SoundEffect(self, "drop", .3)
+        self.eliminate_phage_fx = SoundEffect(self, "eliminate", 1)
         self.graticule_y = 0
         self.set_background()
         self.set_lattice()
@@ -715,12 +733,18 @@ class Paddles(GameChild):
                     location.center = center
 
     def explode_mines(self):
+        count = 0
+        total_x = 0
         for side in self.active_mines:
             for mine in side:
+                count += 1
+                total_x += mine.location.centerx
                 mine.set_frameset("explode")
         for location in self.graticule.locations:
             location.unhide()
-        self.detonate_mine_fx.play()
+        if count:
+            self.detonate_mine_fx.play(float(total_x) / count / \
+                                       self.get_display_surface().get_width())
 
     def respond(self, event):
         if self.parent.active and not self.parent.ending:
@@ -735,8 +759,11 @@ class Paddles(GameChild):
                 side = self.LEFT if event.command == "release-left" else self.RIGHT
                 if self.active_mines[side]:
                     outgoing = []
+                    count = len(self.active_mines[side])
+                    mine_total_x = 0
                     while self.active_mines[side]:
                         mine = self.active_mines[side][0]
+                        mine_total_x += mine.location.centerx
                         center = mine.location.center
                         mine.set_frameset("explode")
                         mine.location.center = center
@@ -760,19 +787,28 @@ class Paddles(GameChild):
                                     if not found:
                                         outgoing.append((phage, start))
                         self.active_mines[side].remove(mine)
+                    self.detonate_mine_fx.play(float(mine_total_x) / count / \
+                                               self.get_display_surface(). \
+                                               get_width())
                     increase = 0
+                    phage_total_x = 0
                     for record in outgoing:
                         increase += record[1]
+                        phage_total_x += record[0].get_center()[0]
                         self.parent.rails.phages.remove(record[0])
                     self.parent.pulp.score += increase * len(outgoing) * 10
-                    self.detonate_mine_fx.play()
-                    # if outgoing:
-                    #     self.eliminate_phage_fx.play()
+                    if outgoing:
+                        self.eliminate_phage_fx.play(float(phage_total_x) / \
+                                                     len(outgoing) / \
+                                                     self. \
+                                                     display_surface. \
+                                                     get_width())
                     for location in self.graticule.locations:
                         if location.side == side:
                             location.unhide()
                     self.throttle[side] = 0
                 elif self.throttle[side] > 500:
+                    total_x = 0
                     for location in self.graticule.locations:
                         if location.side == side:
                             while True:
@@ -783,8 +819,12 @@ class Paddles(GameChild):
                                     mine.get_current_frameset().reset()
                                     break
                             self.active_mines[side].append(mine)
+                            total_x += mine.location.centerx
                             location.hide()
-                    self.drop_mine_fx.play()
+                    self.drop_mine_fx.play(float(total_x) / \
+                                           len(self.active_mines[side]) / \
+                                           self.get_display_surface(). \
+                                           get_width())
 
     def update(self):
         for ii in xrange(len(self.throttle)):
@@ -1038,7 +1078,7 @@ class Phage(GameChild):
         self.step = random() * .004 - .002 + center
 
     def get_center(self):
-        return self.body[0].location.bottomright
+        return self.body[0].location.midbottom
 
     def update(self):
         step = self.parent.phage_step * self.health
@@ -1165,7 +1205,7 @@ class Animals(GameChild, list):
 
     def __init__(self, parent):
         GameChild.__init__(self, parent)
-        self.collect_token_fx = SoundEffect(self, "01")
+        self.collect_token_fx = SoundEffect(self, "power-up", .7)
         font = Font(self.get_resource("display", "font"), 18)
         color = Color(0, 0, 0)
         for glyph in [u"馬", u"羊", u"雉", u"龍", u"雞", u"豕", u"狗", u"牛"]:
@@ -1219,7 +1259,9 @@ class Animals(GameChild, list):
                     location.centerx += paddles.paddle_length + paddles.margin
             if self.in_motion.location.colliderect(paddles.paddles.location):
                 paddles.arrange_graticules(self.index(self.in_motion) + 1)
-                self.collect_token_fx.play()
+                self.collect_token_fx.play(paddles.paddles.location.centerx / \
+                                           float(self.get_display_surface().\
+                                                 get_width()))
                 self.hide()
             else:
                 self.in_motion.move(dy=4)
diff --git a/resource/aud/Knife-Glory/9i.ogg b/resource/aud/Knife-Glory/9i.ogg
deleted file mode 100644 (file)
index c5d167a..0000000
Binary files a/resource/aud/Knife-Glory/9i.ogg and /dev/null differ
diff --git a/resource/aud/Knife-Glory/Mb.ogg b/resource/aud/Knife-Glory/Mb.ogg
deleted file mode 100644 (file)
index 371af5a..0000000
Binary files a/resource/aud/Knife-Glory/Mb.ogg and /dev/null differ
diff --git a/resource/aud/Knife-Glory/No.ogg b/resource/aud/Knife-Glory/No.ogg
deleted file mode 100644 (file)
index 348b0ae..0000000
Binary files a/resource/aud/Knife-Glory/No.ogg and /dev/null differ
diff --git a/resource/aud/Knife-Glory/O0.ogg b/resource/aud/Knife-Glory/O0.ogg
deleted file mode 100644 (file)
index d976b4a..0000000
Binary files a/resource/aud/Knife-Glory/O0.ogg and /dev/null differ
diff --git a/resource/aud/Knife-Glory/detonate-4.ogg b/resource/aud/Knife-Glory/detonate-4.ogg
new file mode 100644 (file)
index 0000000..2d50dea
Binary files /dev/null and b/resource/aud/Knife-Glory/detonate-4.ogg differ
diff --git a/resource/aud/Knife-Glory/drop-1.ogg b/resource/aud/Knife-Glory/drop-1.ogg
new file mode 100644 (file)
index 0000000..84c4161
Binary files /dev/null and b/resource/aud/Knife-Glory/drop-1.ogg differ
diff --git a/resource/aud/Knife-Glory/eE.ogg b/resource/aud/Knife-Glory/eE.ogg
deleted file mode 100644 (file)
index 3dcd1fa..0000000
Binary files a/resource/aud/Knife-Glory/eE.ogg and /dev/null differ
diff --git a/resource/aud/Knife-Glory/eliminate-2.ogg b/resource/aud/Knife-Glory/eliminate-2.ogg
new file mode 100644 (file)
index 0000000..1f6c434
Binary files /dev/null and b/resource/aud/Knife-Glory/eliminate-2.ogg differ
diff --git a/resource/aud/Knife-Glory/lose-health.ogg b/resource/aud/Knife-Glory/lose-health.ogg
new file mode 100644 (file)
index 0000000..28a58a1
Binary files /dev/null and b/resource/aud/Knife-Glory/lose-health.ogg differ
diff --git a/resource/aud/Knife-Glory/no.ogg b/resource/aud/Knife-Glory/no.ogg
deleted file mode 100644 (file)
index 016dd33..0000000
Binary files a/resource/aud/Knife-Glory/no.ogg and /dev/null differ
diff --git a/resource/aud/Knife-Glory/power-up.ogg b/resource/aud/Knife-Glory/power-up.ogg
new file mode 100644 (file)
index 0000000..bf7efe5
Binary files /dev/null and b/resource/aud/Knife-Glory/power-up.ogg differ
diff --git a/resource/aud/Knife-Glory/start.ogg b/resource/aud/Knife-Glory/start.ogg
new file mode 100644 (file)
index 0000000..c11da7e
Binary files /dev/null and b/resource/aud/Knife-Glory/start.ogg differ
diff --git a/resource/aud/Knife-Glory/ww.ogg b/resource/aud/Knife-Glory/ww.ogg
deleted file mode 100644 (file)
index 61b024e..0000000
Binary files a/resource/aud/Knife-Glory/ww.ogg and /dev/null differ
index 819be35..7ca621a 100644 (file)
@@ -6,9 +6,19 @@
 1429
 1295
 1359
-3551
 827
 1425
 1643
 1198
 1014
+888
+522
+938
+843
+1676
+1604
+2181
+1716
+1635
+1510
+1603