diff skaapsteker/sprites/base.py @ 538:c1b0ad1c0932

Hook up projectile sounds.
author Simon Cross <hodgestar@gmail.com>
date Sun, 10 Apr 2011 00:33:06 +0200
parents a7b7694644a5
children b7f912705adb
line wrap: on
line diff
--- a/skaapsteker/sprites/base.py	Sun Apr 10 00:32:24 2011 +0200
+++ b/skaapsteker/sprites/base.py	Sun Apr 10 00:33:06 2011 +0200
@@ -11,6 +11,7 @@
 from ..engine import OpenDialog, AddSpriteEvent
 from .. import data
 from .. import dialogue
+from .. import sound
 
 
 TILE_SIZE = (64, 64)
@@ -180,6 +181,7 @@
         else:
             pos = pygame.Rect(self.rect.midright, (0, 0))
         projectile = cls(pos, direction=self.facing, hits=Player, source=self)
+        projectile.launch()
         AddSpriteEvent.post(projectile)
 
     def do_attack(self):
@@ -303,6 +305,7 @@
 
     collision_layer = PROJECTILE_LAYER
     collides_with = set()
+    launch_sound = None, None
 
     gravitates = False
 
@@ -316,6 +319,8 @@
         self.facing = direction
         self.source = source # source of the projectile (may be None)
         self._update_image(True)  # ensure we get the direction right
+        if self.launch_sound[0]:
+            sound.load_sound(self.launch_sound[0], self.launch_sound[0], self.launch_sound[1])
 
         if isinstance(hits, tuple):
             self.hits = hits + (Geography,)
@@ -333,6 +338,10 @@
         self.collide_rect.move_ip(shift)
         self.deltav(dv)
 
+    def launch(self):
+        if self.launch_sound[0]:
+            sound.play_sound(self.launch_sound[0])
+
     def explode(self):
         self.kill()