猫史档案馆


【Python作品分享】空白

用户:红领巾k2FM红领巾k2FM查看:0 回复:2 评论:0 创建时间:2022-01-25T14:07:05


【作品展示】

center_image

 

【作品介绍】

超级玛丽

 

【作品源代码】

import pgzrun
WIDTH = 1200
HEIGHT = 600

glasss = []

blackboard = Actor('荷兰')
blackboard.pos = 600,300
ground = Actor('大地')
ground.x = WIDTH/2
ground.y = 700-HEIGHT/10

ground2 = Actor('大地2')
ground2.x = ground.x - 1200
ground2.y = 700-HEIGHT/10

dolphin = Actor('海豚')
dolphin.y = ground.top
dolphin.x = WIDTH/3
for i in range(3):
    glass = Actor('喵')
    glass.pos = 100*(2+i),100*(1+i)
    glasss.append(glass)

def draw():
    blackboard.draw()
    for glass in glasss:
        glass.draw()
    ground.draw()
    ground2.draw()
    dolphin.draw()
    

def update():
    for glass in glasss:
        if keyboard.d:
            glass.x -= 10
            ground.x -= 10
            ground2.x -= 10
        if ground2.x == 600:
            ground.x = -600
        if ground.x == 600:
            ground2.x = -600

        if keyboard.a:
            glass.x += 10
            ground.x += 10
            ground2.x += 10
        if ground2.x == 600:
            ground.x = 1800
        if ground.x == 600:
                ground2.x = 1800

        if keyboard.k:
            dolphin.y -= 5
    isPlayerOnGround = False
    for glass in glasss:
        if abs(dolphin.bottom-glass.top) < 10 \
            and glass.left - dolphin.left < dolphin.width*2/3 \
            and dolphin.right - glass.right < dolphin.width*2/3 :
            isPlayerOnGround = True
            dolphin.bottom = glass.top
            if keyboard.d:
                ground.x -= 10
                ground2.x -= 10
            if ground2.x == 600:
                ground.x = -600
            if ground.x == 600:
                ground2.x = -600
        
            if keyboard.a:
                ground.x += 10
                ground2.x += 10
            if ground2.x == 600:
                ground.x = 1800
            if ground.x == 600:
                ground2.x = 1800

            if keyboard.k:
                dolphin.y -= 5

    if dolphin.bottom < ground.top:
        dolphin.y += 5
pgzrun.go()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
梁壹Andy梁壹Andy

imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E6%90%93%E5%A4%B4.gif"alt="emotion_编程猫_搓头"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%97%A8%E8%B5%B7%E6%9D%A5.gif"alt="emotion_编程猫_嗨起来"

点赞0


评论


褚岩分身褚岩分身

您也用一起学?

 

点赞0


评论