用户:泯·灭查看:0 回复:0 评论:0 创建时间:2020-06-26T15:56:31
【作品展示】

【作品介绍】
喵
【作品源代码】
import pgzrun
from random import randint
WIDTH = 700
HEIGHT =700
score1= 0
score2= 0
button1 = Actor('button1_on')
button1.pos = WIDTH/4, HEIGHT/2+60
button2 = Actor('button2_on')
button2.pos = WIDTH-WIDTH/4, HEIGHT/2+60
time_left = 10
game_over = False
def draw():
screen.fill('lightyellow')
button1.draw()
button2.draw()
screen.draw.text('score1:'+str(score1), color='yellow',
center=(WIDTH/4, 150), fontsize=50)
screen.draw.text('score2:'+str(score2), color='lightgreen',
center=(WIDTH-WIDTH/4, 150), fontsize=50)
screen.draw.text('timeleft:'+str(time_left), color='lightblue',
center=(WIDTH-WIDTH/2, 40), fontsize=50)
if game_over:
screen.fill('lightblue')
screen.draw.text('Final Score1:'+str(score1), color='white',center=(WIDTH/4, 120), fontsize=50)
screen.draw.text('Final Score2:'+str(score2), color='white',
center=(WIDTH-WIDTH/4, 120), fontsize=50)
def on_key_down(key):
global score1, score2
if not game_over:
if key == keys.A:
button1.image = 'button1_off'
score1 = score1+1
if key==keys.L:
button2.image = 'button2_off'
score2 = score2+1
def on_key_up(key):
if key == keys.A:
button1.image ='button1_on'
if key == keys.L:
button2.image = 'button2_on'
def update_time_left():
global time_left, game_over
if score1>0 or score2 > 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