"""
飞扬小鸟Python精灵模块简版
"""
from sprites import *
width,height = 480,360
bimages = [f'res/costume{i}.png' for i in range(1,5)]
screen = Screen()
screen.setup(width,height)
screen.bgpic('res/背景.png')
screen.title('飞扬小鸟Python精灵模块简版')
leftkey = Mouse(1) # 左键
# 循环播放背景音乐
Sprite(visible=False).play('res/音乐.wav',loop=True)
dummy = Sprite(visible=False)
dummy.addy(100)
dummy.write("飞扬小鸟Python精灵模块简版",align='center',font=('楷体',22,'normal'))
dummy.addy(-80)
dummy.write("writed by lixingqiu",align='center',font=('黑体',18,'bold'))
dummy.addy(-100)
dummy.write("click to start the game",align='center',font=('宋体',12,'normal'))
while not leftkey.down():screen.update()
dummy.clear()
# 新建上下管道
up_pip = Sprite('res/上管道.png',pos=(width,height//2))
down_pip = Sprite('res/下管道.png',pos=(width,-height//2))
bird = Sprite(shape=bimages,pos=(-100,0)) # 新建小鸟
bird.dy = 0 # 垂直速度
bird.die = False # 描述死亡
def alt_costume(): # 切换造型
bird.nextcostume() # 下一个造型
if bird.die == False: # 如果没死
screen.ontimer(alt_costume,130) # 130毫各后继续
alt_costume()
running = True # 控制while循环
clock = Clock() # 新建时钟对象
以下代码省略......
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

