summaryrefslogtreecommitdiff
path: root/src/sliceitoff/game/show.py
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-28 22:28:45 +0200
committerViljami Ilola <+@hix.fi>2024-03-28 22:28:45 +0200
commitf894c2fd09ed17540c49cb4083573861ded76554 (patch)
treecedbe5bab1b5f91b7e3dfb70c17f5114034e700e /src/sliceitoff/game/show.py
parentf502b21183d307fcab9b353aa18609d15c3547f1 (diff)
Show as sprite group with update
Diffstat (limited to 'src/sliceitoff/game/show.py')
-rw-r--r--src/sliceitoff/game/show.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/sliceitoff/game/show.py b/src/sliceitoff/game/show.py
index 07146c3..018e555 100644
--- a/src/sliceitoff/game/show.py
+++ b/src/sliceitoff/game/show.py
@@ -4,24 +4,27 @@ from .anykey import anykey
class Show(pygame.sprite.Group):
""" To show some sprites and quit on any key """
- def __init__(self, sprites = []):
+ def __init__(self, sprites = None, active = True):
super().__init__()
self.add(sprites)
+ self.active = active
+ self.explode = False
self.fadeout = 1_000
- self.timeout = 5_000
+ self.timeout = 15_000
- def step(self, dt):
- if self.fadeout < 0:
- return False
-
- if self.timeout < 0:
+ def update(self, dt = 0, **kwargs):
+ super().update(dt = dt, explode = self.explode, **kwargs)
+ if self.fadeout <= 0:
+ self.active = False
+ elif self.timeout <= 0:
if anykey():
- return False
+ self.fadeout = 0
self.fadeout -= dt
- self.update(explode=dt)
- return True
-
- if anykey():
- self.timeout = 0
- self.timeout -= dt
- return True
+ self.explode = True
+ else:
+ if anykey():
+ self.timeout = 0
+ self.timeout -= dt
+
+ def sprites(self):
+ return super().sprites() if self.active else None \ No newline at end of file