diff options
author | Viljami Ilola <+@hix.fi> | 2024-03-16 11:11:56 +0200 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-03-16 11:11:56 +0200 |
commit | 85adc89f53763b4390f7e51161a05ab394143152 (patch) | |
tree | b63de708a75d7ea3fd961f8d63ca2af381cb66c5 /src/sliceitoff/status | |
parent | 5d921239e0577988e2b7814025149d9160ecbdda (diff) |
drafting game components
Diffstat (limited to 'src/sliceitoff/status')
-rw-r--r-- | src/sliceitoff/status/__init__.py | 1 | ||||
-rw-r--r-- | src/sliceitoff/status/status.py | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/sliceitoff/status/__init__.py b/src/sliceitoff/status/__init__.py new file mode 100644 index 0000000..2a4c93e --- /dev/null +++ b/src/sliceitoff/status/__init__.py @@ -0,0 +1 @@ +from .status import Status
\ No newline at end of file diff --git a/src/sliceitoff/status/status.py b/src/sliceitoff/status/status.py new file mode 100644 index 0000000..afff7f7 --- /dev/null +++ b/src/sliceitoff/status/status.py @@ -0,0 +1,45 @@ +import os +import pygame + +from display import Scaling +from images import images + +class LetterSprite(pygame.sprite.Sprite): + def __init__(self, image, x, y): + super().__init__() + self.image = image + self.rect = self.image.get_rect().move(x,y) + + +class Status(): + def __init__(self, scaling: Scaling = None): + self.scaling = scaling if scaling else Scaling(50,0,0) + self.score = 6234823999 + self.health = 3 + self.updated = True + self.sprites = pygame.sprite.Group() + + + def __update_sprites(self): + self.sprites.empty() + y = 28000 + score_str="{:010d}".format(self.score) + for letter, x in zip(score_str, range(30000,40000,1000)): + self.sprites.add(LetterSprite( + images[f"letter_{letter}"], + x*self.scaling.scale+self.scaling.left, + y*self.scaling.scale+self.scaling.top)) + self.updated = False + + def add_score(self, score_to_add): + self.updated = True + self.score += score_to_add + + def get_sprites(self): + if self.updated: + self.__update_sprites() + return self.sprites + + def __del__(self): + pass +
\ No newline at end of file |