diff options
author | Viljami Ilola <+@hix.fi> | 2024-04-07 23:25:09 +0300 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-04-07 23:25:09 +0300 |
commit | 6ba20c61a04c688120161f6c5fbb56102f8082ef (patch) | |
tree | 33291a2c494b8fe5e126e31b5ce719aa0df0feec /src/sliceitoff/game/initials.py | |
parent | d2e42bfa99d8bb417d8eaf365d290a071ad49b7f (diff) |
exploding sprites and groups as their own. more refactoring.
Diffstat (limited to 'src/sliceitoff/game/initials.py')
-rw-r--r-- | src/sliceitoff/game/initials.py | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/sliceitoff/game/initials.py b/src/sliceitoff/game/initials.py index 7811afa..9fb5a68 100644 --- a/src/sliceitoff/game/initials.py +++ b/src/sliceitoff/game/initials.py @@ -3,45 +3,30 @@ import pygame from screens import initials_screen -from .anykey import anykey +from .explodeout import ExplodeOutGroup -class Initials(pygame.sprite.Group): +class Initials(ExplodeOutGroup): """ Sprite group that asks initials to self.name from user """ def __init__(self): super().__init__() self.add(initials_screen("")) self.name = "" - self.explode = False - self.active = True - self.fadeout = 1_000 def update(self, dt = 0, **kwargs): """ Does it all. Reads keyboard and updates screen """ - if not self.active: - return - - super().update(dt = dt, explode = self.explode, **kwargs) - - if self.explode: - if self.fadeout <= 0: - self.active = False - else: - if anykey(): - self.fadeout = 0 - self.active = False - self.fadeout -= dt + if not super().update(dt = dt, **kwargs): return for event in pygame.event.get(): if event.type == pygame.QUIT: - self.explode = True + self.do_fadeout() break if event.type == pygame.KEYDOWN: if event.key in ( pygame.K_ESCAPE, pygame.K_KP_ENTER, pygame.K_RETURN): - self.explode = True + self.do_fadeout() break if event.key in ( pygame.K_RSHIFT, |