find_in_square与爆炸效果举例1.py

0 Comments

李兴球Python精灵模块find_in_square与爆炸效果举例

"""
  find_in_square与爆炸效果举例1.py
  本程序单击鼠标进行角色查找,采用onclick绑定的方式进行。
  本程序需要sprites模块V1.469版本支持。
  请用cmd命令打开管理员,输入以下命令进行更新。
  pip install sprites --upgrade
"""
from sprites import *

bug = Sprite()
screen = bug.screen
screen.setup(800,600)
w = screen.cv
bug2 = Sprite()
bug2.left(90)
bug3 = Sprite()
bug3.right(90)
bug4 = Sprite()
bug4.right(180)

def baozha(x,y):
    global running
    # 在x,y为中心边长为2区域内查找角色
    sprite = find_in_square(x,y)[0]
    explode(sprite,爆炸表)    
    sprite.hide()
    running = running -1
    
爆炸表 = ['res/explosion0.png','res/explosion1.png']

bugs = [bug,bug2,bug3,bug4]
 
bugs[0].onclick(baozha) 
bugs[1].onclick(baozha) 
bugs[2].onclick(baozha) 
bugs[3].onclick(baozha)

clock = Clock()
running = len(bugs)
while running:
    for bug in bugs:
        bug.fd(1)
    clock.tick(30) 

end = Sprite('blank')
end.write("Game Over") 

标签:

发表评论