blob: c3fe43695ebe1faf3df2f135ec804051c1dfb1dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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 = 1_000
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
|