diff options
Diffstat (limited to 'src/sliceitoff/game/gameplay.py')
-rw-r--r-- | src/sliceitoff/game/gameplay.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/sliceitoff/game/gameplay.py b/src/sliceitoff/game/gameplay.py index 12daeaf..6869cbb 100644 --- a/src/sliceitoff/game/gameplay.py +++ b/src/sliceitoff/game/gameplay.py @@ -17,18 +17,14 @@ class Gameplay: self.enemies = enemies def fire(self): - hitbox = self.field.slice( + """ Lazer is fired. Actions to be taken. """ + zap_sprite = self.field.slice( self.player.position, self.player.direction, 4_500) - hit = False - if hitbox is not None: - for enemy in self.enemies.sprites(): - if hitbox.colliderect(enemy.rect): - hit = True - break - - if hit: + if not zap_sprite: + return False + if pygame.sprite.spritecollideany(zap_sprite, self.enemies): if Stats.lose_life(): return True self.field.kill_if_not_colliding(self.enemies.sprites()) |