""" Reads user input and does actions when game play is on. """ import pygame from .anykey import anykey class Show(pygame.sprite.Group): """ To show some sprites and quit on any key """ def __init__(self, sprites = None, active = True): super().__init__() self.add(sprites) self.active = active self.explode = False self.fadeout = 1_000 self.timeout = 15_000 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(): self.fadeout = 0 self.fadeout -= dt self.explode = True else: if anykey(): self.timeout = 0 self.timeout -= dt def sprites(self): return super().sprites() if self.active else None