From aa00efba55147a32ae9aa71b86789616e11f16dc Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 6 Mar 2016 01:43:58 +0200 Subject: [PATCH] Check bullets and enemies are on the same level --- koperkapel/gamelib/enemy_roach.py | 1 + koperkapel/scenes/level.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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) -- 2.34.1