summaryrefslogtreecommitdiff
path: root/src/sliceitoff/status/status.py
blob: cacc84a956b8c5baa831bbe283e31401fa9e6292 (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
28
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 = (
                "\x12{:1d} \x03{:1d} \x0e{:02d} \xfe{:02d} "
                "\x0f{:08d}").format(
                    Stats.level,
                    Stats.lives,
                    Stats.bonus // 1000,
                    99 if Stats.percent == 100 else int(Stats.percent),
                    Stats.score)
        if self.old_srt != score_str:
            self.empty()
            self.add( TextPage(
                    score_str,
                    pos = (0, 220_000),
                    size = (12_000, 0),
                    font = 'lcd') )