猫史档案馆


【Python作品分享】game-1

用户:某只衫(bilibili名称:小五洋)某只衫(bilibili名称:小五洋)查看:0 回复:1 评论:0 创建时间:2022-07-27T16:08:11


【作品展示】

center_image

 

【作品介绍】

abababab

 

【作品源代码】

import pgzrun
import random as r
WIDTH = 450   # 设置窗口的宽度
HEIGHT = 1000 # 设置窗口的高度
TITLE = "123"
zhujie = Actor('op')
bj = Actor('background')
bj1 = Actor('background')
bj.y = 852/2
bj1.y = -852/2
fan = Actor('asd')
jn = Actor('qwe')
bz = Actor('hero_blowup')
boss = Actor('op')
fan.x =r.randint(0,350)
fan.y =0
fenshu = 0
b = []
e = []
o = []
z2 = 0
z3 = 0
x  = 100
y = 100
jn1 = Actor('awds')
hp =100
wd = 0
boss = Actor('ss')
np = 100
x1 = 100
y1 =100
bosshp =0
xb = 500
yb =0
boss.y =100000000
bs= 0
def draw():
    bj.draw()
    bj1.draw()
    fan.draw()
    zhujie.draw()
    for i in b:        
        i.draw()
    for i in e:
        i.draw()
    for i in o:
        i.draw()
    for i in range(10):
        screen.draw.line((x,y+i),(x+hp,y+i),'green')
    for i in range(10):
        screen.draw.line((x1, y1+i), (x1+np, y1+i ), 'blue')
    if fenshu > 100:
        boss.draw()       
        bs = 1
        for i in range (40):
            screen.draw.line((0, 0+i), (xb+bosshp, yb+i), 'red')
    screen.draw.text(str(fenshu), (50, 50), fontsize=50, color='red')


def update():  # 更新函数
    global z2,e,z3,jn,fenshu,jn1,wd,np,hp,bosshp,bs
    fan.y += 5
    if fan.y > 1000 :
        fan.y = 0
        fan.x = r.randint(0, 450)
    if bj.y > 852/2 + 852:
        bj.y = -852/2
    else:
        bj1.y += 1
    if bj1.y > 852 + 852/2:
        bj1.y = -852/2
    else:
        bj.y += 1
    for i in b:
        i.y -= 5
        #i.x -= r.randint(-5,5)
    
    if keyboard.q:
        if z2 == 0: 
            jn =Actor('喵')
            jn.x = zhujie.x
            jn.y = zhujie.y
            e.append(jn)
            z2 = 1
    for i in range(len(e)):
        e[i].y -= 5
        if e[i].y < -10 :
            z2 = 0
            del(e[i])
    if keyboard.e:
        if np >= 50 : 
            if z3 == 0:
                jn1 = Actor('sand')
                jn1.x = zhujie.x
                jn1.y = zhujie.y
                o.append(jn1)
                z3 = 1
                np -= 50
    for i in range(len(o)):
        o[i].y -= 5
        if o[i].y < -10:
            z3 = 0
            del(o[i])
    if jn.colliderect(fan):
        if wd == 0:
            fenshu += 1
            fan.y = 0
            fan.x = r.randint(0,450)
            wd = 0
            jn.y = -1000
    if jn1.colliderect(fan):
        fenshu += 1
        fan.y = 0
        fan.x = r.randint(0, 450)
        wd = 0

    for i in range(len(b)):
        if b[i].colliderect(fan):
            if wd == 0:
                fenshu += 1
                fan.y = -300
                fan.x = r.randint(0, 450)
                wd = 0
                if np < 200:
                    np += 20
                del(b[i])    
                break
        if b[i].y < -30 :
            del(b[i])
            break
        if b[i].colliderect(boss):
            bosshp -= 30
            print(bosshp)
            del(b[i])
            break
    if zhujie.colliderect(fan):
        hp -= 1
        fan.y = 0
        fan.x = r.randint(0,450)
    if keyboard.z:
        if np > 50:
            hp += 50
            np -= 50
    if fenshu >=100 :
        boss.y = -200
        bs = 0
        for i in range(150):
            boss.y += 1
        bs = 0


def on_mouse_move(pos, rel, buttons):
    global x,y,hp,x1,y1
    zhujie.x = pos[0]
    zhujie.y = pos[1]
    x = pos[0] - 50
    y = pos[1] + 50
    x1= pos[0] - 50
    y1 = pos[1] + 70


def on_mouse_down():
    global np
    zd1 = Actor('子弹头气(gas)_爱给网_aigei_com')
    zd = Actor('s')
    zd2 = Actor('子弹头气(gas)_爱给网_aigei_com')
    zd3 = Actor('子弹头气(gas)_爱给网_aigei_com')
    zd4 = Actor('子弹头气(gas)_爱给网_aigei_com')
    zd.x = zhujie.x
    zd.y =zhujie.y
    zd1.x = zhujie.x - 50
    zd1.y = zhujie.y
    zd2.x = zhujie.x + 50
    zd2.y = zhujie.y
    b.append(zd1)
    b.append(zd)
    b.append(zd2)
    np -= 1
    #sounds.喵1.play()
    music.play_once('喵')
pgzrun.go()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
穹天穹天

给下素材

点赞0


评论