From 98d91824cacec97c581ae0a4f1efd9fa3faa18ab Mon Sep 17 00:00:00 2001 From: Viljami Ilola <+@hix.fi> Date: Sat, 23 Mar 2024 22:19:00 +0200 Subject: player through SingleGroup --- src/sliceitoff/status/status.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/sliceitoff/status/status.py') diff --git a/src/sliceitoff/status/status.py b/src/sliceitoff/status/status.py index a337a5b..cacc84a 100644 --- a/src/sliceitoff/status/status.py +++ b/src/sliceitoff/status/status.py @@ -1,18 +1,16 @@ -import os import pygame -from display import Scaling -from images import Images, Fonts from stats import Stats from text import TextPage -class Status(): +class Status(pygame.sprite.Group): def __init__(self): - self.sprites = pygame.sprite.Group() + super().__init__() + self.old_srt = None - def update(self, dt): - """ Update sprites basis of dt. dt = milliseconds from last update """ - + def update(self, **kwargs): + """ Rebuilds statusline if needed """ + super().update(**kwargs) score_str = ( "\x12{:1d} \x03{:1d} \x0e{:02d} \xfe{:02d} " "\x0f{:08d}").format( @@ -21,8 +19,10 @@ class Status(): Stats.bonus // 1000, 99 if Stats.percent == 100 else int(Stats.percent), Stats.score) - self.sprites = TextPage( - score_str, - pos = (0, 220_000), - size = (12_000, 0), - font = 'lcd') + if self.old_srt != score_str: + self.empty() + self.add( TextPage( + score_str, + pos = (0, 220_000), + size = (12_000, 0), + font = 'lcd') ) -- cgit v1.2.3