Play weapon sounds when firing.
authorSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 20:47:26 +0000 (22:47 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 20:47:26 +0000 (22:47 +0200)
koperkapel/scenes/level.py
koperkapel/weapons.py

index 50ec80864287ebb325b47439d973520ec1c8f164..ea32bc1eaa63107850cb9c3b82e79f22cc8a63e1 100644 (file)
@@ -197,6 +197,7 @@ class GameLevelScene(BaseLevelScene):
     @defer_to_update
     def _fire_weapon(self, world):
         weapon = weapon_by_name(world.weapons.current)
+        weapon.play_sound()
         if weapon.bullet_range > 0:
             # ranged, fire bullet
             print("Pew.")
index f07caedb2404ae802bc94f280ea839fc9a38f621..ee83eb816c6eb5c9295db74c05fb78199d506e56 100644 (file)
@@ -18,6 +18,10 @@ class Weapon:
         if sound:
             self.sound = sounds.load(sound)
 
+    def play_sound(self):
+        if self.sound:
+            self.sound.play()
+
 
 WEAPONS = [
     Weapon("spit", damage=1, bullet_range=2, can_tape=False,