From 11394cc68ca2f312c93706c52bb02a0e0999b01f Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sat, 5 Mar 2016 22:47:26 +0200 Subject: [PATCH] Play weapon sounds when firing. --- koperkapel/scenes/level.py | 1 + koperkapel/weapons.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/koperkapel/scenes/level.py b/koperkapel/scenes/level.py index 50ec808..ea32bc1 100644 --- a/koperkapel/scenes/level.py +++ b/koperkapel/scenes/level.py @@ -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.") diff --git a/koperkapel/weapons.py b/koperkapel/weapons.py index f07caed..ee83eb8 100644 --- a/koperkapel/weapons.py +++ b/koperkapel/weapons.py @@ -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, -- 2.34.1