From: Neil Date: Sat, 5 Mar 2016 23:43:58 +0000 (+0200) Subject: Check bullets and enemies are on the same level X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=aa00efba55147a32ae9aa71b86789616e11f16dc;p=koperkapel.git Check bullets and enemies are on the same level --- diff --git a/koperkapel/gamelib/enemy_roach.py b/koperkapel/gamelib/enemy_roach.py index 83523b6..b09c3aa 100644 --- a/koperkapel/gamelib/enemy_roach.py +++ b/koperkapel/gamelib/enemy_roach.py @@ -15,6 +15,7 @@ def get_enemy_roach(level): roach.health = 5 roach.angle = 0 roach.level = level + roach.level_layer = 'floor' # always the case for now roach.move = partial(move, roach) roach.last_moved = 0 roach.last_attacked= 0 diff --git a/koperkapel/scenes/level.py b/koperkapel/scenes/level.py index 379b8bf..d4f3b0d 100644 --- a/koperkapel/scenes/level.py +++ b/koperkapel/scenes/level.py @@ -259,7 +259,7 @@ class GameLevelScene(BaseLevelScene): def _check_for_bullet_hits(self): for bullet in list(self._bullets): for enemy in list(self._enemies): - if enemy.collidepoint(bullet.pos): + if enemy.collidepoint(bullet.pos) and bullet.level_layer == enemy.level_layer: self._hit_enemy(enemy, bullet.weapon) self._bullets.remove(bullet)