diff options
Diffstat (limited to 'src/sliceitoff/field/field.py')
-rw-r--r-- | src/sliceitoff/field/field.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/sliceitoff/field/field.py b/src/sliceitoff/field/field.py index 82391d6..5769bfc 100644 --- a/src/sliceitoff/field/field.py +++ b/src/sliceitoff/field/field.py @@ -3,11 +3,9 @@ import pygame from random import randrange from display import Scaling, INTERNAL_WIDTH, INTERNAL_HEIGHT -from stats import Stats DEBUG = os.getenv("DEBUG") - class FieldSprite(pygame.sprite.Sprite): def __init__(self, area: tuple): super().__init__() @@ -67,19 +65,20 @@ class ExplodedField(FieldSprite): class Field(pygame.sprite.LayeredUpdates): initial_area = (320_000, 220_000) - def __init__(self): + def __init__(self, stats = None): super().__init__() self.add(FieldSprite( (0, 0, *__class__.initial_area) )) self.area_full = __class__.initial_area[0] * __class__.initial_area[1] + self.stats = stats def calculate_current_area(self): return sum( s.area[2]*s.area[3] for s in self.active_sprites() ) def update_stats(self): """ calculates remaining area and remaining percentage """ - Stats.percent = 100 * self.calculate_current_area() / self.area_full + self.stats.percent = 100 * self.calculate_current_area() / self.area_full if DEBUG: - print(f"FIELD: {Stats.percent}") + print(f"FIELD: {self.stats.percent}") def slice( self, @@ -152,4 +151,4 @@ class Field(pygame.sprite.LayeredUpdates): else: self.explode(field.area) field.remove(self) - Stats.field_count=len(self.active_sprites()) + self.stats.field_count=len(self.active_sprites()) |