猫史档案馆


【Python作品分享】极速连击【作品秀】

用户:一只诺如影一只诺如影查看:1 回复:4 评论:1 创建时间:2020-06-19T13:17:26


【作品展示】

center_image

 

【作品介绍】

天哪,我终于做出了它,这是我第一次做出超过30行代码的游戏,快来测一测你的手速吧!

 

【作品源代码】

import pgzrun

WIDTH = 310
HEIGHT = 450
score = 0
button = Actor("button1_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="red",center=(WIDTH / 2, 40),
                    fontsize=50)
    if game_over:
        screen.fill("cyan")
        screen.draw.text("Final Scores: " + str(score),
                        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


回复

上一页1 页 / 共 1下一页
蕉饼蕉饼

ed

 

点赞0


评论


AlcalaAlcala

行啊

点赞0


评论


lsk666666lsk666666

。。。

点赞0


评论


卫道士32_32*2没了卫道士32_32*2没了

yuyuyuyuyuyuyuyuyuyuuyuyuyuyuyuuyuyuyuyuyuyu

点赞0


评论