summaryrefslogtreecommitdiff
path: root/src/sliceitoff/game/gameplay.py
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-24 01:22:39 +0200
committerViljami Ilola <+@hix.fi>2024-03-24 01:22:39 +0200
commitcd128f5bc4fae39fb7e77683758d437f64eb4203 (patch)
treef4f3efbca3e11e7f6fb73a227ad09ef11918ec48 /src/sliceitoff/game/gameplay.py
parent4353670f0cee67550b20dfcfd51b81386372f358 (diff)
gameover, level x and level up screens
Diffstat (limited to 'src/sliceitoff/game/gameplay.py')
-rw-r--r--src/sliceitoff/game/gameplay.py14
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())