From 947df85053af2704ce1a17daf1fab13e273f0cc5 Mon Sep 17 00:00:00 2001 From: Viljami Ilola <+@hix.fi> Date: Sat, 23 Mar 2024 21:02:56 +0200 Subject: remove cross dependencies. moving logic towards game/... --- src/sliceitoff/game/gameplay.py | 5 +++-- src/sliceitoff/game/level.py | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/sliceitoff/game') diff --git a/src/sliceitoff/game/gameplay.py b/src/sliceitoff/game/gameplay.py index 6296a5a..e691b84 100644 --- a/src/sliceitoff/game/gameplay.py +++ b/src/sliceitoff/game/gameplay.py @@ -14,13 +14,14 @@ class Gameplay: self.status = status self.player = player self.field = field - self.field = enemies + self.enemies = enemies def fire(self): if self.player.fire_lazer(): - field.kill_if_not_colliding(enemies.sprites()) if Stats.lose_life(): return True + self.field.kill_if_not_colliding(self.enemies.sprites()) + self.field.update_stats() return Stats.percent < 20 def quit(self): diff --git a/src/sliceitoff/game/level.py b/src/sliceitoff/game/level.py index a417d8f..7c58b86 100644 --- a/src/sliceitoff/game/level.py +++ b/src/sliceitoff/game/level.py @@ -15,7 +15,7 @@ class Level: self.field = Field() self.enemies = Enemies(field = self.field) self.player = Player(field = self.field, enemies = self.enemies) - self.gameplay = Gameplay(player = self.player, status = self.status) + self.gameplay = Gameplay(player = self.player, status = self.status, field = self.field, enemies = self.enemies) self.obj_classes = ( self.status, self.field, @@ -26,8 +26,10 @@ class Level: for obj in self.obj_classes: obj.update(dt = dt) - Stats.update_bonus(dt) + self.enemies.hit_walls(self.field.active_sprites()) + Stats.update_bonus(dt) + self.display.update( ( self.status.sprites, self.field, -- cgit v1.2.3