-
Notifications
You must be signed in to change notification settings - Fork 0
/
bomb.py
70 lines (59 loc) · 2.3 KB
/
bomb.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2008 Ferraro Luciano (aka lux) <luciano.ferraro@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pygame
from pil import *
class AnimatedSprite (pygame.sprite.Sprite):
placed = False
vpos = None
def __init__(self, core, image):
pygame.sprite.Sprite.__init__(self)
self.core = core
self.speed = 5*self.core.scale
self.delay, self.frames = load_gif(image, self.core.xscale,self.core.yscale)
self.frames = load_gif(image)[1]
self.sprite = pygame.sprite.RenderPlain(self)
def DirectMove (self, vpos):
self.vpos = vpos
self.rect = self.rect.fit(self.core.rects[vpos][1])
def Place (self, vpos):
self.placed = True
self.frame = 0
self.image = self.frames[0]
self.rect = self.image.get_rect()
self.DirectMove(vpos)
self.clock = pygame.time.Clock()
self.time = 0
def Explode (self):
################
self.placed = False
def update (self):
if not self.placed:
return
self.time += self.clock.tick()
if self.time >= self.delay:
self.time = 0
self.frame += 1
if self.frame >= len(self.frames):
self.Explode()
return
self.image = self.frames[self.frame]
self.rect = self.image.get_rect().move(self.rect.topleft)
self.colorkey = self.image.get_at((0,self.image.get_height()-1))
self.image.set_colorkey(self.colorkey)
pygame.event.pump()
def BombSprite (core):
return AnimatedSprite(core, "sprites/bombs/animbomb.gif")