diff options
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, |