blob: 0349b094ddab1001cce2dae19a93b1dfc45487e5 (
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
34
35
36
37
38
|
""" game.explodeout - For showing explogind effect and waiting for a key """
import pygame
from sliceitoff.sfx import sfx
from .anykey import anykey
class ExplodeOutGroup(pygame.sprite.Group):
""" Sprite group that just counts down feadeout/explosion or a key """
def __init__(self, active = True):
super().__init__()
self.explode = False
self.active = active
self.fadeout = 1_000
def update(self, dt = 0, **kwargs):
""" Just does the explosion and marks group inactive """
if not self.active:
return False
super().update(dt = dt, explode = self.explode, **kwargs)
if self.explode:
if self.fadeout <= 0:
self.active = False
else:
if anykey():
self.fadeout = 0
self.active = False
self.fadeout -= dt
return True
return True
def do_fadeout(self):
""" Just kicks off exploding phase """
if self.explode:
return
sfx.play("glass")
self.explode = True
|