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/explodeout.py | |
parent | d2e42bfa99d8bb417d8eaf365d290a071ad49b7f (diff) |
exploding sprites and groups as their own. more refactoring.
Diffstat (limited to 'src/sliceitoff/game/explodeout.py')
-rw-r--r-- | src/sliceitoff/game/explodeout.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/sliceitoff/game/explodeout.py b/src/sliceitoff/game/explodeout.py new file mode 100644 index 0000000..34bd9fe --- /dev/null +++ b/src/sliceitoff/game/explodeout.py @@ -0,0 +1,34 @@ +""" game.explodeout - For showing explogind effect and waiting for a key """ +import pygame + +from .anykey import anykey + +class ExplodeOutGroup(pygame.sprite.Group): + """ Sprite group that just counts down feadeout/explosion or a key """ + def __init__(self, active = True): + super().__init__() + self.explode = False + self.active = active + self.fadeout = 1_000 + + def update(self, dt = 0, **kwargs): + """ Just does the explosion and marks group inactive """ + if not self.active: + return False + + 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 True + return True + + def do_fadeout(self): + """ Just kicks off exploding phase """ + self.explode = True |