blob: bf0e864e5c590cd26ea9f63768630898d90978a6 (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import os
import pygame
from display import Scaling
from images import Images
class LetterSprite(pygame.sprite.Sprite):
def __init__(self, image, pos):
super().__init__()
self.image = image
self.rect = self.image.get_rect().move(pos)
class Status():
def __init__(self):
self.score = 6234823999
self.health = 3
self.updated = True
self.sprites = pygame.sprite.Group()
def __update_sprites(self):
self.sprites.empty()
y = 28_000
score_str="{:010d}".format(self.score)
for letter, x in zip(score_str, range(30_000,40_000,1_000)):
self.sprites.add(LetterSprite(
Images.surfaces[f"letter_{letter}"],
Scaling.scale_to_display((x,y)) ))
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
|