用户:
真诚的皮皮蟹SdR_查看:0 回复:0 评论:0 创建时间:2022-07-14T13:04:24
【作品展示】

【作品介绍】
做的真好!
【作品源代码】
import pgzrun
import random
WIDTH = 790
HEIGHT = 470
background = Actor("荆棘丛林")
bar_up = Actor("红色陨石")
bar_down = Actor("灰色陨石")
bird = Actor("龙")
bar_up.x = 100
bar_up.y = 600
bar_down.x = 300
bar_down.y = 100
bird.x = 50
bird.y = HEIGHT/2
score = 0
speed = 1
def draw():
background.draw()
bird.draw()
bar_down.draw()
bar_up.draw()
screen.draw.text(str(score), (30, 30), fontsize=50, color="green")
def update():
global score, speed
bird.y = bird.y + 2
bar_up.x = bar_up.x - 2
bar_down.x = bar_down.x - 2
if (bar_up.x < 0):
bar_up.x = WIDTH
bar_down.x = WIDTH
bar_up.y = random.randint(0, HEIGHT)
bar_down.y = random.randint(0, HEIGHT)
score = score + 1
if score % 5 == 0:
speed = speed + 1
if bird.colliderect(bar_up) or bird.colliderect(bar_down):
print('游戏失败')
bar_up.x = 300
bar_up.y = 600
bar_down.x = 300
bar_down.y = 100
bird.x = 50
bird.y = HEIGHT/2
score = 0
speed = 1
def on_mouse_down():
bird.y = bird.y - 50
pgzrun.go()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn