用户:
1086爱编程查看:0 回复:1 评论:0 创建时间:2022-04-24T17:27:15
【作品展示】

【作品介绍】
a,一个拼手速作品
【作品源代码】
import pgzrun
WIDTH = 310
HEIGHT = 450
score = 0
button = Actor('button1_on')
button.pos = WIDTH / 2, HEIGHT / 2 + 60
time_left = 10
game_over = False
def draw():
screen.fill("lightblue")
button.draw()
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(score), color="white",
center=(WIDTH / 2, 150), fontsize=50)
def on_mouse_down(pos):
global score
if button.collidepoint(pos):
button.image = "button1_off"
score += 1
def on_mouse_up():
button.image = "button1_on"
def update_time_left():
global time_left, game_over
if score > 0:
if time_left >0:
time_left -= 1
else:
game_over = True
clock.schedule_interval(update_time_left, 1.0)
pgzrun.go()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn