From 975e5dca49fb09fe2f762462f1c337c0d63735bf Mon Sep 17 00:00:00 2001 From: Viljami Ilola <+@hix.fi> Date: Wed, 20 Mar 2024 17:46:10 +0200 Subject: exploding text --- src/sliceitoff/game/show.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/sliceitoff/game/show.py (limited to 'src/sliceitoff/game/show.py') 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 -- cgit v1.2.3