diff options
author | Viljami Ilola <+@hix.fi> | 2024-03-28 23:34:19 +0200 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-03-28 23:34:19 +0200 |
commit | 27c7e16e4bd808ce1176f18b7a78c02ff4fa88ee (patch) | |
tree | a585d5ef853a0f8ffd5000cbdc9b0c4257163e53 /src/sliceitoff/game/initials.py | |
parent | f894c2fd09ed17540c49cb4083573861ded76554 (diff) |
fonts under text, more sprite.Groups
Diffstat (limited to 'src/sliceitoff/game/initials.py')
-rw-r--r-- | src/sliceitoff/game/initials.py | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/sliceitoff/game/initials.py b/src/sliceitoff/game/initials.py index a317dd9..49db3d6 100644 --- a/src/sliceitoff/game/initials.py +++ b/src/sliceitoff/game/initials.py @@ -1,26 +1,47 @@ +""" game.initials - Use will be asked for initials """ import pygame from screens import initials_screen +from .anykey import anykey + class Initials(pygame.sprite.Group): + """ 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, **kwargs): - super().update(**kwargs) + def update(self, dt = 0, **kwargs): + 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 + return - def step(self): for event in pygame.event.get(): if event.type == pygame.QUIT: - return False + self.explode = True + break if event.type == pygame.KEYDOWN: if event.key in ( pygame.K_ESCAPE, pygame.K_KP_ENTER, pygame.K_RETURN): - return False + self.explode = True + break if event.key in ( pygame.K_RSHIFT, pygame.K_LSHIFT, @@ -39,6 +60,5 @@ class Initials(pygame.sprite.Group): elif pygame.key.name(event.key): self.name += pygame.key.name(event.key)[0].upper() self.name = self.name[:3] - self.empty() - self.add(initials_screen(self.name)) - return True + self.empty() + self.add(initials_screen(self.name)) |