• 个人简介

    最新作品:飞机大战2.0

    语言:Python

    import pgzrun
    import random
    import time
    
    WIDTH=600
    HEIGHT=350
    bg=Actor('背景.png')
    bg.x=350
    bg.y=250
    my=Actor('我的战舰.png')
    my.x=300
    my.y=300
    over=Actor('gameover.png')
    over.x=300
    over.y=175
    blood=100.0
    weapons=[]
    your=[]
    yweapons=[]
    flag=True
    bossflag=False
    gametime=0
    bossblood=0
    boss=Actor('boss.png')
    boss.x=10000
    bloodup=100
    bleft=False
    for i in range(3):
        you=Actor('敌方的战舰.png')
        you.x=random.randint(0,600)
        you.y=50
        your.append(you)
    
    def draw():
        global flag
        global blood
        global bossblood
        bg.draw()
        if flag:
            my.draw()
            for i in weapons:
                i.draw()
            for i in yweapons:
                i.draw()
            for i in your:
                i.draw()
            if bossflag:
                boss.draw()
                screen.draw.text('your:'+str(int(blood))+' boss:'+str(int(bossblood)),(10,300), fontsize=50,color='red')
                screen.draw.text(str(gametime//60),(10,10), fontsize=50,color='red')
            else:
                screen.draw.text(str(int(blood)),(10,300), fontsize=50,color='red')
                screen.draw.text(str(gametime//60),(10,10), fontsize=50,color='yellow')
        else:
            over.draw()
            screen.draw.text(str(gametime//60),(10,10), fontsize=50,color='yellow')
    
    def on_key_down(key):
        if key==keys.SPACE:
            weapon=Actor('我的子弹.png')
            weapon.x=my.x
            weapon.y=my.y
            weapons.append(weapon)
    
    def update():
        global blood
        global flag
        global gametime
        global bossflag
        global bossblood
        global bloodup
        global bleft
        if keyboard.left:
            my.x-=3
        if keyboard.right:
            my.x+=3
        if keyboard.up:
            my.y-=1.5
        if keyboard.down:
            my.y+=1.5
        for i in weapons:
            i.y-=7
        for i in yweapons:
            i.y+=6
        for i in your:
            for j in weapons:
                if i.colliderect(j):
                    i.x=random.randint(0,600)
                    i.y=50
                    j.y=-50
        if random.randint(1,100)<5:
            yweapon=Actor('敌人的子弹.png')
            yweapon.x=your[random.randint(0,len(your)-1)].x
            yweapon.y=50
            yweapons.append(yweapon)
        if random.randint(1,300)<2:
            you=Actor('敌方的战舰.png')
            you.x=random.randint(0,600)
            you.y=50
            your.append(you)
        for i in yweapons:
            if i.colliderect(my):
                blood-=2.0
                i.y=500
        if blood<bloodup:
            blood+=0.01
        if blood<=0:
            flag=False
        if gametime>=5999 and gametime%6000<1 and not bossflag:
            bossblood=(bloodup-100)/2*1.5+100
            bossflag=True
            boss.x=random.randint(0,600)
            boss.y=80
        if bossflag:
            if random.randint(1,100)<5:
                for i in range(3):
                    yweapon=Actor('敌人的子弹.png')
                    yweapon.x=boss.x
                    yweapon.y=50
                    yweapons.append(yweapon)
            for i in weapons:
                if boss.colliderect(i):
                    bossblood-=2
                    i.y=-500
            if bossblood<100:
                bossblood+=0.001
            if bleft:
                boss.x+=1
            else:
                boss.x-=1
            if boss.x<0:
                bleft=True
            elif boss.x>600:
                bleft=False
            if bossblood<=0:
                gametime+=60
                bossbloos=0
                bossflag=False
                boss.x=10000
                bloodup+=20
                blood=bloodup
        else:
            if flag:
                gametime+=1
    
    pgzrun.go()
    
    

    记得准备好素材哦

  • 通过的题目

  • 最近活动

    This person is lazy and didn't join any contests or homework.
  • 最近编写的题解

    This person is lazy and didn't write any solutions.

题目标签

客观题
1