From 5c5df6e068b2957987cb51b34d6930769424f8ca Mon Sep 17 00:00:00 2001 From: Viljami Ilola <+@hix.fi> Date: Fri, 29 Mar 2024 00:30:39 +0200 Subject: stats as object --- src/sliceitoff/game/gameplay.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/sliceitoff/game/gameplay.py') diff --git a/src/sliceitoff/game/gameplay.py b/src/sliceitoff/game/gameplay.py index 028536c..ef708c4 100644 --- a/src/sliceitoff/game/gameplay.py +++ b/src/sliceitoff/game/gameplay.py @@ -1,8 +1,6 @@ """ Reads user input and does actions when game play is on. """ import pygame -from stats import Stats - class Gameplay: """ Logic of the playfield """ def __init__( @@ -10,11 +8,13 @@ class Gameplay: player = None, field = None, status = None, - enemies = None): + enemies = None, + stats = None): self.status = status self.player = player self.field = field self.enemies = enemies + self.stats = stats def fire(self): """ Lazer is fired. Actions to be taken. """ @@ -24,16 +24,16 @@ class Gameplay: 4_000) if not zap_sprite: return False - Stats.add_score(-500) + self.stats.add_score(-500) if pygame.sprite.spritecollideany(zap_sprite, self.enemies): - if Stats.lose_life(): + if self.stats.lose_life(): return True self.field.kill_if_not_colliding(self.enemies.sprites()) self.field.update_stats() - return Stats.percent < 20 + return self.stats.percent < 20 def quit(self): - Stats.lives = 0 + self.stats.lives = 0 return True def step(self): -- cgit v1.2.3