summaryrefslogtreecommitdiff
path: root/src/sliceitoff/game/show.py
blob: 07146c390388756db7f6a3a1a46a26906e6ccc3c (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
""" 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 = []):
        super().__init__()
        self.add(sprites)
        self.fadeout = 1_000
        self.timeout = 5_000
        
    def step(self, dt):
        if self.fadeout < 0:
            return False
        
        if self.timeout < 0:
            if anykey():
                return False
            self.fadeout -= dt
            self.update(explode=dt)
            return True
            
        if anykey():
            self.timeout = 0
        self.timeout -= dt
        return True