上传文件至 ''
This commit is contained in:
parent
7ffe7cf598
commit
ffd8643a97
|
@ -0,0 +1,83 @@
|
|||
class Bomb(object):
|
||||
# 初始化爆炸
|
||||
def __init__(self, screen, type):
|
||||
self.screen = screen
|
||||
if type == 'enemy':
|
||||
# 加载爆炸资源
|
||||
self.mImages = [
|
||||
pygame.image.load("./feiji/enemy0_down" + str(v) + ".png") for v in range(1, 5)]
|
||||
else:
|
||||
# 加载爆炸资源
|
||||
self.mImages = [pygame.image.load(
|
||||
"./feiji/hero_destroy" + str(v) + ".png") for v in range(1, 4)]
|
||||
|
||||
self.mImages += self.mImages
|
||||
|
||||
# 设置当前爆炸播放索引
|
||||
self.mIndex = 0
|
||||
# 爆炸位置
|
||||
self.mPos = [0, 0]
|
||||
# 是否可见
|
||||
self.mVisible = False
|
||||
|
||||
# 设置位置
|
||||
def action(self, rect):
|
||||
# 触发爆炸方法draw
|
||||
# 爆炸的坐标
|
||||
self.mPos[0] = rect.left
|
||||
self.mPos[1] = rect.top
|
||||
# 打开爆炸的开关
|
||||
self.mVisible = True
|
||||
|
||||
# 绘制爆炸
|
||||
def draw(self):
|
||||
if not self.mVisible:
|
||||
return
|
||||
self.screen.blit(self.mImages[self.mIndex], (self.mPos[0], self.mPos[1]))
|
||||
self.mIndex += 1
|
||||
if self.mIndex >= len(self.mImages):
|
||||
# 如果下标已经到最后 代表爆炸结束
|
||||
# 下标重置 mVisible重置
|
||||
self.mIndex = 0
|
||||
self.mVisible = Falseclass Bomb(object):
|
||||
# 初始化爆炸
|
||||
def __init__(self, screen, type):
|
||||
self.screen = screen
|
||||
if type == 'enemy':
|
||||
# 加载爆炸资源
|
||||
self.mImages = [
|
||||
pygame.image.load("./feiji/enemy0_down" + str(v) + ".png") for v in range(1, 5)]
|
||||
else:
|
||||
# 加载爆炸资源
|
||||
self.mImages = [pygame.image.load(
|
||||
"./feiji/hero_destroy" + str(v) + ".png") for v in range(1, 4)]
|
||||
|
||||
self.mImages += self.mImages
|
||||
|
||||
# 设置当前爆炸播放索引
|
||||
self.mIndex = 0
|
||||
# 爆炸位置
|
||||
self.mPos = [0, 0]
|
||||
# 是否可见
|
||||
self.mVisible = False
|
||||
|
||||
# 设置位置
|
||||
def action(self, rect):
|
||||
# 触发爆炸方法draw
|
||||
# 爆炸的坐标
|
||||
self.mPos[0] = rect.left
|
||||
self.mPos[1] = rect.top
|
||||
# 打开爆炸的开关
|
||||
self.mVisible = True
|
||||
|
||||
# 绘制爆炸
|
||||
def draw(self):
|
||||
if not self.mVisible:
|
||||
return
|
||||
self.screen.blit(self.mImages[self.mIndex], (self.mPos[0], self.mPos[1]))
|
||||
self.mIndex += 1
|
||||
if self.mIndex >= len(self.mImages):
|
||||
# 如果下标已经到最后 代表爆炸结束
|
||||
# 下标重置 mVisible重置
|
||||
self.mIndex = 0
|
||||
self.mVisible = False
|
Loading…
Reference in New Issue