-
Notifications
You must be signed in to change notification settings - Fork 0
/
quarantineMine.py
37 lines (28 loc) · 1.21 KB
/
quarantineMine.py
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
import pygame, threading
import entity
from animation import Animation, ResizeAnimation, ColorFadeAnimation
class QuarantineMine(entity.Entity):
def __init__(self, pos):
self.position = pos
self.exploding = False
anims = {
'idle': Animation("quarintine mine.png"),
'explode': ResizeAnimation("quarintine explosion.png", 30, 0, (0.1, 0.1), (1, 1), (0.5, 0.5)),
'done': ColorFadeAnimation("quarintine explosion.png", 5, 0, (255,255,255,0))
}
super(QuarantineMine, self).__init__(self.position, anims, 'idle')
t = threading.Timer(1.0, self.explode)
t.start()
def update(self):
super(QuarantineMine, self).update()
if self.animName == 'explode' and self.anim.done:
self.changeAnimation('done')
self.exploding = False
elif self.animName == 'done' and self.anim.done:
self.kill()
def explode(self):
self.changeAnimation('explode')
self.rect.center = self.position
sound = pygame.mixer.Sound("data/sounds/mineexplosion.wav")
sound.play()
self.exploding = True