猫史档案馆


【Python作品分享】控制路段

用户:eeeneeen查看:0 回复:0 评论:0 创建时间:2021-10-30T12:41:48


【作品展示】

center_image

 

【作品介绍】

,mhj

 

【作品源代码】

import time
import pgzrun


WIDTH = 1161
HEIGHT = 621
xx = (WIDTH / 2 - 200)
yy = (HEIGHT / 2 + 25)
xxx = (WIDTH / 2 + 200)
yyy = (HEIGHT / 2 + 25)
cy = (HEIGHT / 2 + 30)
h = 7
m = 20
b = 0
r = 0
z = 0
y = 0 

def on_key_down(key):

    if (key == keys.L):
        button.image = "honganniu2"
    if (key == keys.S):
        button3.image = "lananniu2"

def draw():

    global h, m, xx, cy
    screen.fill("lightblue")
    button1.draw()
    button2.draw()
    button.draw()
    button3.draw()
    dang.draw()
    dang1.draw()
    dang2.draw()
    xs.draw()
    xs1.draw()
    car.draw()

def on_key_up(key):

    global r, yy, b, z, xx, xxx, yyy, cy, y
    if (key == keys.L):
        button.image = "honganniu1"
        y = (y + 1)
        dang.image = "wu"
        dang1.image = "wu"
        dang2.image = "wu"
        z = 0
    if (y % 2 == 1):
        dang.image = "weilanshu"
        dang1.image = "weilanshu"
        dang2.image = "weilanheng"
        z = 1
    if (key == keys.S):
        button3.image = "lananniu1"
        r = (r + 1)
        button2.image = "gaoshipai"
        if (r % 2 == 1):
            button2.image = "daoluguanbi"
            b += 1
            if (b % 2 == 1):
                button2.image = "daolukaifang"
                for u in range(100):
                    xx += 1.9
                    yy -= 0.5
                    xxx -= 1.9
                    yyy -= 0.5
                for u in range(100):
                    cy += 2.5
            else:
                for u in range(100):
                    xx -= 1.9
                    yy += 0.5
                    xxx += 1.9
                    yyy += 0.5
                for u in range(100):
                    cy -= 2.5

button = Actor("honganniu1")
button3 = Actor("lananniu1")
button1 = Actor("ditu")
button1.pos = WIDTH/2, HEIGHT/2
button2 = Actor("gaoshipai")
button2.pos = WIDTH/2, HEIGHT/2-90
button.pos = WIDTH/2+300, HEIGHT/2+200
button3.pos = WIDTH/2-300, HEIGHT/2+200
dang = Actor("wu")
dang1 = Actor("wu")
dang.pos = WIDTH/2+400, HEIGHT/2+35
dang1.pos = WIDTH/2-400, HEIGHT/2+25
dang2 = Actor("wu")
dang2.pos = WIDTH/2, HEIGHT/2+200
xs = Actor("xueshengxiangyou")
xs.pos = xx, yy
xs1 = Actor("xueshengxiangzuo")
xs1.pos = xxx, yyy
car = Actor("che")
car.pos = WIDTH/2+0, cy
# while True:
#    m += 1
#    time.sleep(5)
#    if (m == 60):
#        m = 0
#         h += 1
#    print(h, m)
pgzrun.go()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页