From: Simon Cross Date: Sat, 5 Mar 2016 20:47:26 +0000 (+0200) Subject: Play weapon sounds when firing. X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=11394cc68ca2f312c93706c52bb02a0e0999b01f;p=koperkapel.git Play weapon sounds when firing. --- 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,