猫史档案馆


【Python作品分享】2快速点击——单人

用户:Gin琴蕾Gin琴蕾查看:0 回复:0 评论:0 创建时间:2021-08-17T20:19:04


【作品展示】

center_image

 

【作品介绍】

按S开始游戏哦

 

【作品源代码】

import pgzrun
import time
music.play('bgm.mp3')

WIDTH = 喵0
HEIGHT = 480
score = 0
button = Actor("on")
button.pos = WIDTH / 2, HEIGHT / 2 + 60
time_left = 5
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),
                        center=(WIDTH / 2, 250), fontsize=50)
        if score < 25:
            screen.draw.text("Urite Tree",center=(WIDTH / 2, 90), fontsize=50)
        elif score < 35:
            screen.draw.text("Urite Tue", center=(WIDTH / 2, 90), fontsize=50)
        elif score < 37:
            screen.draw.text("Urite One", center=(
                WIDTH / 2, 90), fontsize=50)
        else:    
            screen.draw.text("Urite win", center=(
                WIDTH / 2, 90), fontsize=50)
    if game_over:
        button.pos = WIDTH / 1000, HEIGHT / 1000

def on_key_down(key):
    global score
    if not game_over:
        if key == keys.S:
            button.image = "off"
            score += 1
            

def on_key_up():
    button.image = "on"

def updat_time_left():
    global time_left, game_over
    if score > 0:
        if time_left > 0:
            time_left -= 1
        else:
            game_over = True


clock.schedule_interval(updat_time_left, 1.0)

pgzrun.go()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页