from pgzrun import *
from save import *
WIDTH = 1400
HEIGHT = 700
sounds.bg.play(-1)
bomb = Actor("bomb.png", [100, 625]) # 炸弹
bg = Actor("bg.png") # 背景
dragon = Actor("dragon.png", [1330, 300]) # 火龙
lose = Actor("lose.png", [1500, 1500]) # 失败
win = Actor("win.png", [1500, 1500]) # 成功
position = []
#{
for i in range(22):
for j in range(13):
position.append([150+i*50,75+j*50])
#}
fire_list = []
for pos in position:
f = Actor("fire.png", pos)
fire_list.append(f)
def draw():
bg.draw()
dragon.draw()
for f in fire_list:
f.draw()
bomb.draw()
lose.draw()
win.draw()
def on_key_down():
music.play_once("walk.mp3")
if keyboard.right == True:
bomb.x = bomb.x + 50
if keyboard.left == True:
bomb.x = bomb.x - 50
if keyboard.up == True:
bomb.y = bomb.y - 50
if keyboard.down == True:
bomb.y = bomb.y + 50
#{
if keyboard.s == True:
save_pic()
if bomb.collidelist(fire_list) != -1: # 如果碰到fire_list中的任何一个雪块
music.play_once("fail.mp3")
sounds.bg.stop()
lose.pos = [700, 350] # 将失败画面的位置设置在窗口中心
if bomb.colliderect(dragon): # 如果碰到恶龙
music.play_once("win.mp3")
sounds.bg.stop()
win.pos = [700, 350] # 将胜利画面的位置设置在窗口中心
def on_mouse_down(pos):
for f in fire_list:
if f.collidepoint(pos):
fire_list.remove(f)
#}
go()