From 727b66f6cdbcec6a74d14bf030c5e8c55e0fb370 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 6 Mar 2016 01:59:59 +0200 Subject: [PATCH] Roach hit sounds --- koperkapel/gamelib/enemy_roach.py | 4 ++++ koperkapel/scenes/level.py | 1 + 2 files changed, 5 insertions(+) diff --git a/koperkapel/gamelib/enemy_roach.py b/koperkapel/gamelib/enemy_roach.py index 95805be..c419af5 100644 --- a/koperkapel/gamelib/enemy_roach.py +++ b/koperkapel/gamelib/enemy_roach.py @@ -3,6 +3,7 @@ import random from pgzero.clock import each_tick, unschedule +from pgzero.loaders import sounds from functools import partial from ..roaches import t32_roaches, WorldRoach, default_rats, default_robots @@ -15,6 +16,7 @@ def get_enemy_roach(level): roach.health = 5 roach.damage = 1 roach.angle = 0 + roach.hit_sound = sounds.load('enemy_hit') roach.level = level roach.level_layer = 'floor' # always the case for now roach.move = partial(move, roach) @@ -33,6 +35,7 @@ def get_rat(level): roach.health = 10 roach.damage = 2 roach.angle = 0 + roach.hit_sound = sounds.load('enemy_hit') roach.level = level roach.level_layer = 'floor' # always the case for now roach.move = partial(move, roach) @@ -52,6 +55,7 @@ def get_robot(level): roach.damage = 5 roach.angle = 0 roach.level = level + roach.hit_sound = sounds.load('enemy_hit') roach.level_layer = 'floor' # always the case for now roach.move = partial(move, roach) roach.last_moved = 0 diff --git a/koperkapel/scenes/level.py b/koperkapel/scenes/level.py index d4f3b0d..40674dc 100644 --- a/koperkapel/scenes/level.py +++ b/koperkapel/scenes/level.py @@ -242,6 +242,7 @@ class GameLevelScene(BaseLevelScene): def _hit_enemy(self, enemy, weapon): enemy.health -= weapon.damage + enemy.hit_sound.play() if enemy.health <= 0: self._level.remove_enemy(enemy) self._enemies.remove(enemy) -- 2.34.1