猫史档案馆


【Python作品分享】我的文件【作品秀】

用户:编程大史编程大史查看:0 回复:1 评论:0 创建时间:2023-11-25T12:43:24


【作品展示】

center_image

 

【作品介绍】

 

【作品源代码】

from pgzrun import*
from random import*

score = 0

state = "ready"

WIDTH = 984
HEIGHT = 5喵

bg2 = Actor("像素蓝雀1.png")
bg1 = Actor("背景.png")
bg3 = Actor("像素蓝雀1.png")
#over = Actor("over.png")
#zd = Actor("r.png")


def on_key_down():
    global state
    if keyboard.space == True:
        state = "run"


h = []
z = []

def hb():
    if state == "run":

        bg3 = Actor("像素蓝雀1.png")
        bg3.x = 150
        bg3.y = 150


#clock.schedule_interval(hb, 1)


def move():
    
    if keyboard.space == True:
        bg3.y -= 5
    else:
        bg3.y += 3
    


def draw():
    global state, score
    if state == "ready":
        bg2.draw()

    if state == "run":
        bg1.draw()
        bg3.draw()
        bg3.x = 250
        
        for n in h:
            n.draw()
        screen.draw.text(
            "score: "+str(score),
            fontsize=30,
            center=[喵, 38]
        )
        
        

        for b in z:
            b.draw()

    if state == "over":
        over.draw()
        screen.draw.text(
            str(score),
            fontsize=80,
            center=[178, 110],
        )


def d():
    if state == "run":
        for n in h:
            n.y = n.y + 4


def 喵():
    if state == "run":
        for b in z:
            b.y = b.y + 3


def update():
    if state == "run":
        d()
        喵()
        move()


score = 0


def on_mouse_down(pos):
    global score, state

    for n in h:

        if n.collidepoint(pos):
            score = score + 1
            h.remove(n)

        for b in z:

            if b.collidepoint(pos):
                state = "over"


go()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
编程大史编程大史

print("6")

点赞1


评论