summaryrefslogtreecommitdiff
path: root/src/sliceitoff/game
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-20 17:46:10 +0200
committerViljami Ilola <+@hix.fi>2024-03-20 17:46:10 +0200
commit975e5dca49fb09fe2f762462f1c337c0d63735bf (patch)
tree4c837b346d7b7e4a9246c1be846f48d787a327ba /src/sliceitoff/game
parent398eebe7829622c6983cb28528f2208b4d596f32 (diff)
exploding text
Diffstat (limited to 'src/sliceitoff/game')
-rw-r--r--src/sliceitoff/game/__init__.py1
-rw-r--r--src/sliceitoff/game/show.py33
2 files changed, 34 insertions, 0 deletions
diff --git a/src/sliceitoff/game/__init__.py b/src/sliceitoff/game/__init__.py
index 87cb41b..d578385 100644
--- a/src/sliceitoff/game/__init__.py
+++ b/src/sliceitoff/game/__init__.py
@@ -1,2 +1,3 @@
from .gameplay import Gameplay
from .level import Level
+from .show import Show
diff --git a/src/sliceitoff/game/show.py b/src/sliceitoff/game/show.py
new file mode 100644
index 0000000..f81c211
--- /dev/null
+++ b/src/sliceitoff/game/show.py
@@ -0,0 +1,33 @@
+""" Reads user input and does actions when game play is on. """
+import pygame
+
+class Show:
+ """ To show some sprites and quit on any key """
+ def __init__(self, sprites = []):
+ self.sprites = sprites
+ self.fadeout = 500
+ self.timeout = 5_000
+
+ def step(self, dt):
+ if self.fadeout < 0:
+ return False
+
+ if self.timeout < 0:
+ for event in pygame.event.get():
+ if event.type in (
+ pygame.MOUSEBUTTONDOWN,
+ pygame.KEYDOWN,
+ pygame.QUIT):
+ return False
+ self.fadeout -= dt
+ self.sprites.update(explode=dt)
+ return True
+
+ for event in pygame.event.get():
+ if event.type in (
+ pygame.MOUSEBUTTONDOWN,
+ pygame.KEYDOWN,
+ pygame.QUIT):
+ self.timeout = 0
+ self.timeout -= dt
+ return True