用户:元气猫查看:0 回复:1 评论:0 创建时间:2021-12-07T21:06:44
【作品展示】

【作品介绍】
测试你的手速
【作品源代码】
import pgzrun
WIDTH = 620
HEIGHT = 450
score = 0
time_left = 10
game_over = False
def update_time_left():
global time_left, game_over
if time_left > 0 and score >= 1:
time_left -= 1
elif time_left <= 0 and score >= 1:
game_over = True
clock.schedule_interval(update_time_left, 1.0)
def draw():
global score , time_left
screen.fill('lightblue')
screen.draw.text('Score:' + str(score), color='white',
center=(WIDTH / 2, 90), fontsize=50)
screen.draw.text('Time left:' + str(time_left),
color='white', center=(WIDTH / 2, 40),
fontsize=50)
if game_over:
screen.fill('lightblue')
screen.draw.text('Final Score:' + str(int((score-1) / 10)) + '/s', color='orange',
center=(WIDTH/2, 150), fontsize=50)
def on_mouse_down():
global score
if game_over:
score += 0
else:
score += 1
pgzrun.go()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn