用户:电竞皮皮虾查看:0 回复:1 评论:0 创建时间:2021-07-17T09:43:52
【作品展示】

【作品介绍】
瞎闹鸟飞飞有点不会怎样让它撞柱子可以解输
以及不会柱子循环向左走
【作品源代码】
import pgzrun # 导入游戏库
WIDTH = 288
HEIGHT = 512 # 根据背景图的大小设置窗口大小
background = Actor("background")
bird = Actor("r_bird")
bird.x = 50 # 小鸟的横纵坐标固定
bird.y = HEIGHT/2
guan_up = Actor("guan_up")
guan_up.x = 240 # 坐标选择默认是图形中心点
guan_up.y = 0
guan_down = Actor("guan_down")
guan_down.x = 240
guan_down.y = 450
def draw(): # 模板,每帧重复执行
background.draw()
bird.draw()
guan_up.draw()
guan_down.draw()
def update():
guan_up.x = guan_up.x - 2# 让管子往左移,实现小鸟在飞。
guan_down.x = guan_down.x - 2
bird.y = bird.y + 2
def on_key_down(): # 按一个键盘上的按键(任何按键都行),质询下面语句。
bird.y = bird.y-50
pgzrun.go() # 游戏开始运行。
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cnimport pgzrun # 导入游戏库
import sys
WIDTH = 288
HEIGHT = 512 # 根据背景图的大小设置窗口大小
background = Actor("background")
bird = Actor("r_bird")
bird.x = 50 # 小鸟的横纵坐标固定
bird.y = HEIGHT/2
guan_up = Actor("guan_up")
guan_up.x = 240 # 坐标选择默认是图形中心点
guan_up.y = 0
guan_down = Actor("guan_down")
guan_down.x = 240
guan_down.y = 450
def draw(): # 模板,每帧重复执行
background.draw()
bird.draw()
guan_up.draw()
guan_down.draw()
def update():
guan_up.x = guan_up.x - 2# 让管子往左移,实现小鸟在飞。
guan_down.x = guan_down.x - 2
if guan_up.x < 0:
guan_up.x = 288
if guan_down.x < 0:
guan_down.x = 288
bird.y = bird.y + 2
if bird.colliderect(guan_up) or bird.colliderect(guan_down):
print("游戏结束")
sys.exit()
def on_key_down(): # 按一个键盘上的按键(任何按键都行),质询下面语句。
bird.y = bird.y-50
pgzrun.go() # 游戏开始运行。
可以参考一下pygame zero的官方教程
#执行代码获取链接
print("".join(chr(x) for x in list([104, 116, 116, 112, 115, 58, 47, 47, 112, 121, 103, 97, 109, 101, 45, 122, 101, 114, 111, 46, 114, 101, 97, 100, 116, 104, 101, 100, 111, 99, 115, 46, 105, 111, 47, 122, 104, 95, 67, 78, 47, 109, 97, 115, 116, 101, 114])))
点赞0
评论