diff options
author | Viljami Ilola <+@hix.fi> | 2024-03-29 00:30:39 +0200 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-03-29 00:30:39 +0200 |
commit | 5c5df6e068b2957987cb51b34d6930769424f8ca (patch) | |
tree | 1f6ce6ff479ee787a3da6f51a9c337bcd24b841a /src/sliceitoff/status | |
parent | 27c7e16e4bd808ce1176f18b7a78c02ff4fa88ee (diff) |
stats as object
Diffstat (limited to 'src/sliceitoff/status')
-rw-r--r-- | src/sliceitoff/status/status.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/sliceitoff/status/status.py b/src/sliceitoff/status/status.py index ad3034c..bbe9a03 100644 --- a/src/sliceitoff/status/status.py +++ b/src/sliceitoff/status/status.py @@ -1,23 +1,28 @@ +""" status.status - The statusline bottom of screen showinf all stats """ import pygame -from stats import Stats from text import TextPage class Status(pygame.sprite.Group): - def __init__(self): + """ Statusline bottom of screen """ + def __init__(self, stats = None): super().__init__() + self.stats = stats self.old_srt = None def update(self, **kwargs): """ Rebuilds statusline if needed """ super().update(**kwargs) + percent = int(self.stats.percent) + if percent == 100: + percent = 99 score_str = ( - f"\xee\x12\xef{Stats.level:<2d}" - f"\xec\x03\xef{Stats.lives:<2d}" - f"\xed\x0e\xef{Stats.bonus // 1000:<3d}" - f"\xe9\xfe\xef{99 if Stats.percent == 100 else int(Stats.percent):<3d}" - f"\xea\x0f\xef{Stats.enemies-Stats.field_count:<3d}" - f"{Stats.score:08d}") + f"\xee\x12\xef{self.stats.level:<2d}" + f"\xec\x03\xef{self.stats.lives:<2d}" + f"\xed\x0e\xef{self.stats.bonus // 1000:<3d}" + f"\xe9\xfe\xef{percent:<3d}" + f"\xea\x0f\xef{self.stats.enemies-self.stats.field_count:<3d}" + f"{self.stats.score:08d}") if self.old_srt != score_str: self.empty() self.add( TextPage( |