summaryrefslogtreecommitdiff
path: root/src/sliceitoff/status/status.py
blob: ea93b88074323cae290aca2fe4d86b2dde01bb91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pygame

from stats import Stats
from text import TextPage

class Status(pygame.sprite.Group):
    def __init__(self):
        super().__init__()
        self.old_srt = None
        
    def update(self, **kwargs):
        """ Rebuilds statusline if needed """
        super().update(**kwargs)
        score_str = (
                f"\x12{Stats.level:<2d}"
                f"\x03{Stats.lives:<2d}"
                f"\x0e{Stats.bonus // 1000:<3d}"
                f"\xfe{99 if Stats.percent == 100 else int(Stats.percent):<3d}"
                f"\x0f{Stats.enemies-Stats.field_count:<3d}"
                f"{Stats.score:08d}")
        if self.old_srt != score_str:
            self.empty()
            self.add( TextPage(
                    score_str,
                    pos = (2_000, 220_000),
                    size = (12_000, 0),
                    font = 'lcd') )