From 87cd7293498d6b30389e056a59b2e69eb7b3a418 Mon Sep 17 00:00:00 2001 From: Viljami Ilola <+@hix.fi> Date: Sat, 23 Mar 2024 20:19:38 +0200 Subject: enemies as group --- src/sliceitoff/game/gameplay.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/sliceitoff/game/gameplay.py') diff --git a/src/sliceitoff/game/gameplay.py b/src/sliceitoff/game/gameplay.py index cc20c3b..6296a5a 100644 --- a/src/sliceitoff/game/gameplay.py +++ b/src/sliceitoff/game/gameplay.py @@ -5,14 +5,22 @@ from stats import Stats class Gameplay: """ Logic of the playfield """ - def __init__(self, player = None, field = None, status = None): + def __init__( + self, + player = None, + field = None, + status = None, + enemies = None): self.status = status self.player = player self.field = field + self.field = enemies def fire(self): - if self.player.fire_lazer() and Stats.lose_life(): - return True + if self.player.fire_lazer(): + field.kill_if_not_colliding(enemies.sprites()) + if Stats.lose_life(): + return True return Stats.percent < 20 def quit(self): -- cgit v1.2.3