python探索南极

代码:

from pgzrun import *
import time
import random

#你可能不对劲 别想着盗作品哦~
bg0=Actor('背景', pos=(300, 169))
tv=Actor('小电视', pos=(300, 169))
nanji=Actor('2048南极洲奥运会', pos=(300, 169))
bad=Actor('⚡可怕的温室气体⚡', pos=(300, 169))
bad1=Actor('⚡可怕的温室气体⚡1', pos=(300, 169))
nanji1=Actor('南极奥运会', pos=(300, 169))
nanji2=Actor('南极奥运会开幕式', pos=(300, 169))
mapmax=Actor('地图', pos=(300, 169))
swim=Actor('游泳馆', pos=(461,247))
mapmax=Actor('地图', pos=(300, 169))
swimmap=Actor('游泳馆地图', pos=(300, 169))
yz=Actor('泳者', pos=(110, 68))
yz2=Actor('敌方泳者', pos=(110, 120))
yz3=Actor('敌方泳者', pos=(110, 180))
yz4=Actor('敌方泳者', pos=(110, 250))
win1=Actor('别太在乎输赢', pos=(300, 169))
playground=Actor('体育馆-跑道', pos=(295,140))
pgmap=Actor('体育馆地图', pos=(300, 169))
slaa=Actor('史莱姆A', pos=(50, 140))
slab=Actor('史莱姆B', pos=(50, 215))
win2=Actor('别太在乎输赢2', pos=(300, 169))
zm=Actor('字幕背景', pos=(300, 300))
gymmap=Actor('射击场地图', pos=(300, 169))
bz=Actor('靶子', pos=(300, 169))
no=Actor('叉', pos=(58259, 169))
win3=Actor('别太在乎输赢3', pos=(300, 169))
biu=Actor('射击场', pos=(157,155))
rock=Actor('攀岩场', pos=(190,291))
ball=Actor('球场', pos=(63,40))
pandamap=Actor('攀岩地图', pos=(300, 169))
panda=Actor('攀爬者', pos=(300, 300))
win4=Actor('别太在乎输赢4', pos=(300, 169))
basketballmap=Actor('球场地图', pos=(300, 169))
ikun=Actor('ikun', pos=(100, 200))
basketball=Actor('篮球~', pos=(144, 230))
cutegg=Actor('可爱的篮筐碰撞箱', pos=(460, 124))
win5=Actor('别太在乎输赢5', pos=(300, 169))
nextl=Actor('下一关', pos=(40, 305))
snowmountain=Actor('雪山机械', pos=(300, 169))
factory_1=Actor('工厂第一关', pos=(300, 169))
twoone=Actor('二氧化碳', pos=(545, 90))
twoone1=Actor('二氧化碳', pos=(545, 90))
dududa=Actor('导弹炮', pos=(65, 143))    
hunbupa=Actor('碱石灰', pos=(16100, 140))
factory_2=Actor('工厂第二关', pos=(300, 169))
bing1=Actor('小蓝冰冰', pos=(165, 150))
bing2=Actor('小蓝冰冰', pos=(310, 150))
bing3=Actor('小蓝冰冰', pos=(460, 150))
button=Actor('button', pos=(300, 288))
fanying=Actor('反应堆', pos=(300, 169))
en=Actor('环境', pos=(300, 169))
choose1=Actor('这个计划我投了!', pos=(127, 111))
choose2=Actor('移山计划', pos=(252, 237))
choose3=Actor('丸辣', pos=(338, 130))
choose4=Actor('稳辣', pos=(433, 258))
choose5=Actor('可怜', pos=(511, 119))
jieju=Actor('结局', pos=(300, 169))

state=0
score=0
lzs=['在中国南极长城站,每逢新年,会敲响一口大钟,庆祝新年的到来。',
'除了人们熟知的企鹅,南极还有一种叫做南极蠓的昆虫,它能在南极的极端环境中生存。',
'南极洲记录到的最低温度是-89.2°C',
'南极洲是世界上风速最强的地区之一,最高风速可达每小时320公里,接近普通台风风速的三倍',
'南极冰层平均厚度为1.9公里,最厚的地方达到了约4.8公里,几乎相当于16座纽约帝国大厦的高度。',
'在南极的冬天,海冰每天会扩大约10万平方公里,直到扩大到比夏季多2000万平方公里,几乎等于它自身的面积。',
'如果南极冰层全部融化,南极大陆将会“弹起来”约500米之多,这种现象称为“冰后回弹”,但整个回弹过程需要大约10000年。']
h=random.randint(0,6)
lzs1=lzs[h]

#原作者 丁湛曦(蓝冰)
jinpai=0
spacean=0
spaceand=0
yz_speed=random.randint(8,12)
yz2_speed=random.randint(1,3)
yz3_speed=random.randint(1,3)
yz4_speed=random.randint(1,3)
oxy=150
lma_speed=5
lmb_speed=random.uniform(1,1.5)
tili=100
leave_speed=1
zidan=10
power=30
onfloor=True
onhand=True
cifang=5
fly=False
g=0
twoone_speed=random.randint(2,3)
twoone1_speed=random.randint(2,4)
twoone_hp=random.randint(80,100)
twoone1_hp=random.randint(75,90)
def frameplus1():
    slab.frame+=1
    time.sleep(0.1)
        

    
def update():
    global state
    
    if state==8:
        yz2.frame+=1
        yz3.frame+=1
        yz4.frame+=1
        time.sleep(0.1)
    
def ballfalling(powering):
    global g,onhand
    if onhand==True:
        g=0
    
                
def draw():
    global state,yz_speed,yz2_speed,yz3_speed,yz4_speed,oxy
    global tili ,lma_speed,lmb_speed,leave_speed,zidan
    global power,onfloor,score,onhand,cifang,g,spacean
    global score,cifang,jinpai,twoone_speed,twoone_hp
    global twoone1_speed,twoone1_hp,fly,lzs1
    if state==0:
        bg0.draw()
        screen.draw.text("冷知识:"+lzs1,(300,20),"light_gray",10,"仓耳与墨W04")
        screen.draw.text("点击任意处开始",(300,300),"white",20,"仓耳与墨W04")
    elif state==1:
        tv.draw()
        zm.draw()
        zm.opacity=0.5
        screen.draw.text("2024年8月11日,你正在电视前看着奥运会比赛",(300,290),"black",20,"仓耳与墨W04")
        screen.draw.text("由于熬夜太晚,你昏昏沉沉地睡着了(点击任意处继续)",(300,312),"black",20,"仓耳与墨W04")
        
        
    elif state==2:
        nanji.draw()
        zm.draw()
        zm.opacity=0.5
        #原作者 丁湛曦(蓝冰)
        screen.draw.text("醒来,你发现在一个陌生的地方,睁开眼睛,温暖的海风扑面而来。",(300,278),"black",20,"仓耳与墨W04")
        screen.draw.text("过量二氧化碳导致有点闷,但你很快适应了。通过打听路边的机器人",(300,300),"black",20,"仓耳与墨W04")
        screen.draw.text("你了解到这是最后一届奥运会——2048南极奥运会(点击任意处继续)",(300,322),"black",20,"仓耳与墨W04")
    elif state==3:
        bad.draw()
        zm.draw()
        zm.opacity=0.5
        screen.draw.text("随着温室气体的过量排放,温室效应加剧,冰川融化,海平面上升",(300,278),"black",20,"仓耳与墨W04")
        screen.draw.text("气温加剧升高,温带与热带变得干燥,雨林变成了干旱的沙漠",(300,300),"black",20,"仓耳与墨W04")
        screen.draw.text("而极地也无法幸免,连绵的冰川变为无际的汪洋(点击任意处继续)",(300,322),"black",20,"仓耳与墨W04")
    elif state==4:
        bad1.draw()
        zm.draw()
        zm.opacity=0.5
        screen.draw.text("而人类也无法幸免",(300,278),"black",20,"仓耳与墨W04")
        screen.draw.text("繁华的都市被海水吞噬,林立的高楼如今破败不堪",(300,300),"black",20,"仓耳与墨W04")
        screen.draw.text("曾经悬崖旁的村庄,也变为一片废墟(点击任意处继续)",(300,322),"black",20,"仓耳与墨W04")
    elif state==5:
        nanji1.draw()
        zm.draw()
        zm.opacity=0.5
        screen.draw.text("但随着温度提高,南极冰川融化,变得温度适宜",(300,278),"black",20,"仓耳与墨W04")
        screen.draw.text("于是,联合政府决定在南极举办最后一届奥运会,",(300,300),"black",20,"仓耳与墨W04")
        screen.draw.text("以纪念环保拯救行动的开始(点击任意处继续)",(300,322),"black",20,"仓耳与墨W04")
    elif state==6:
        nanji2.draw()
        zm.draw()
        zm.opacity=0.5
        screen.draw.text("而你,也获得了参加的资格",(300,290),"black",20,"仓耳与墨W04")
        screen.draw.text("加油吧!(点击任意处开始)",(300,312),"black",20,"仓耳与墨W04")
    elif state==7:
        
        mapmax.draw()
        swim.draw()
        playground.draw()
        biu.draw()
        rock.draw()
        ball.draw()
        screen.draw.text("金牌数:"+str(jinpai)+"       附:十枚以上金牌解锁隐藏关",(300,20),"white",20,"仓耳与墨W04")
        if jinpai>=10:
            nextl.draw()
    elif state==8:
        
        oxy-=1
        if oxy<0:
            yz_speed=0
        
        swimmap.draw()
        yz.draw()
        yz2.draw()
        yz3.draw()
        yz4.draw()
        
        if yz.x>=520:
            state=9
            win1.frame=0
            jinpai+=1
        if yz2.x>=520:
            state=9
            win1.frame=1
        if yz3.x>=520:
            state=9
            win1.frame=1
        if yz4.x>=520:
            state=9
            win1.frame=1
        if yz2.x<520:
            yz2.x+=yz2_speed
        if yz3.x<520:
            yz3.x+=yz3_speed
        if yz4.x<520:
            yz4.x+=yz4_speed
        
        screen.draw.text("氧气值"+str(oxy)+"O键呼吸,W键加速",(150,20),"white",20,"仓耳与墨W04")
    elif state==9:
        win1.draw()
    elif state==10:
        if slaa.x>=550:
            state=11
            win2.frame=0
            jinpai+=1
        if slab.x>=550:
            state=11
            win2.frame=1
        if tili>20:
            tili-=0.5
        pgmap.draw()
        slaa.draw()
        slab.draw()
        i=random.randint(1,8)
        if i==1:
            frameplus1()
        if slab.x<550:
            slab.x+=lmb_speed
        screen.draw.text("W键加速,S键暂停",(150,20),"white",20,"仓耳与墨W04")
        screen.draw.text(int(tili),(350,300),"orange",40,"仓耳与墨W04")
    elif state==11:
        win2.draw()
    elif state==12:
        gymmap.draw()
        bz.draw()
        no.draw()
        if leave_speed>0:
            if bz.y<200:
                bz.y+=leave_speed
            else:
                leave_speed=leave_speed*-1    
        if leave_speed<0:
            if bz.y>138:
                bz.y+=leave_speed
            else:
                leave_speed=leave_speed*-1
        gymmap.y+=(leave_speed/2)
        screen.draw.text("O键屏息,点击靶标开枪;子弹数:"+str(zidan),(150,20),"white",20,"仓耳与墨W04")
    elif state==13:
        win3.draw()
    elif state==14:
        pandamap.draw()
        panda.draw()
        if power<30:
            power+=1
        if panda.y<300:
            panda.y+=2
        if panda.y>=300:
            if onfloor==False:
                state=15
                win4.frame=1
        if panda.y<30:
            state=15
            win4.frame=0
            jinpai+=1
        screen.draw.text("W键跳,AD键移动;蓄力:"+str(power),(150,20),"white",20,"仓耳与墨W04")
    elif state==15:
        win4.draw()        
    elif state==16:
        cutegg.draw()
        basketballmap.draw()
        ikun.draw()
        basketball.draw()
        screen.draw.text("空格键投篮,WS键前后移动;得分:"+str(score),(160,20),"white",20,"仓耳与墨W04")
        basketball.y+=g//2
        ballfalling(spacean)
        if onhand==True:
            basketball.x=5233
            if ikun.frame==0:
                random_1=random.randint(1,50)
                if random_1==1:
                    ikun.frame=1
            elif ikun.frame==1:
                random_2=random.randint(1,50)
                if random_2==1:
                    ikun.frame=0
            else:
                ikun.frame=0
        if onhand==False:
            ikun.frame=2
            if basketball.x>490:
                if spacean>=0:
                    spacean*=-1
            if basketball.y>250:
                onhand=True
                basketball.x=144
                basketball.y=230
                if cifang>0:
                    cifang-=1
            if basketball.x>600:
                onhand=True
                basketball.x=144
                basketball.y=230
                if cifang>0:
                    cifang-=1
            if basketball.collide_actor(cutegg):
                onhand=True
                basketball.x=144
                basketball.y=230
                score+=1
                if cifang>0:
                    cifang-=1
        if cifang<=0:
            if score>=3:
                state=17
                win5.frame=0
                jinpai+=1
            else:
                state=17
                win5.frame=1
    elif state==17:
        win5.draw()            
    elif state==18:
        snowmountain.draw()
        zm.draw()
        zm.opacity=0.5
        screen.draw.text("荣获许多枚金牌,你决定出去散散步",(300,278),"black",20,"仓耳与墨W04")
        screen.draw.text("在一座高山背后,你发现了一座古老而又巨大的工厂",(300,300),"black",20,"仓耳与墨W04")
        screen.draw.text("它背后 藏着什么秘密(点击任意处继续)",(300,322),"black",20,"仓耳与墨W04")
    elif state==19:
        factory_1.draw()
        twoone.draw()
        twoone1.draw()
        dududa.draw()
        hunbupa.draw()
        if twoone_hp<=0 and twoone1_hp<=0:
            state=20
            bing1.frame=random.randint(0,2)
            bing2.frame=random.randint(0,2)
            bing3.frame=random.randint(0,2)
        if twoone_hp>0:
            if twoone_speed>0:
                if twoone.y<=250:
                    twoone.y+=twoone_speed
                else:
                    twoone_speed*=-1
            if twoone_speed<0:
                if twoone.y>=50:
                    twoone.y+=twoone_speed
                else:
                    twoone_speed*=-1
        if twoone1_hp>0:
            if twoone1_speed>0:
                if twoone1.y<=250:
                    twoone1.y+=twoone1_speed
                   
                else:
                    twoone1_speed*=-1
                    
            if twoone1_speed<=0:
                if twoone1.y>50:
                    twoone1.y+=twoone1_speed
                else:
                    twoone1_speed*=-1
        if twoone_hp<=0:
            twoone.x=10000
        if twoone1_hp<=0:
            twoone1.x=10000
        if fly==True:
            if hunbupa.x>600:
                fly=False
            if hunbupa.collide_actor(twoone):
                twoone_hp-=random.randint(5,8)
            if hunbupa.collide_actor(twoone1):
                twoone1_hp-=random.randint(5,8)
    elif state==20:
        factory_2.draw()
        bing1.draw()
        bing2.draw()
        bing3.draw()
        button.draw()
    elif state==21:
        fanying.draw()    
        zm.draw()
        zm.opacity=0.5
        screen.draw.text("你得以进入工厂,破坏了温室气体反应堆",(300,290),"white",20,"仓耳与墨W04")
        screen.draw.text("按任意处继续",(300,322),"white",20,"仓耳与墨W04")
    elif state==22:
        en.draw()
        choose1.draw()
        choose2.draw()
        choose3.draw()
        choose4.draw()
        choose5.draw()
    elif state==23:
        jieju.draw()
            
            
            
def on_mouse_down(pos):
    global state,yz_speed,yz2_speed,yz3_speed,yz4_speed,oxy
    global zidan,onfloor,power,onhand,cifang,score,jinpai
    if state==0:
        if bg0.collide_point(pos):
            state=1
    elif state==1:
        if tv.collide_point(pos):
            state=2
    elif state==2:
        if nanji.collide_point(pos):
            state=3
    elif state==3:
        if bad.collide_point(pos):
            state=4
    elif state==4:
        if bad1.collide_point(pos):
            state=5
    elif state==5:
        if nanji1.collide_point(pos):
            state=6
    elif state==6:
        if nanji2.collide_point(pos):
            state=7
    elif state==7:
        if swim.collide_point(pos):
            state=8
            oxy=150
            yz.x=120
            yz2.x=120
            yz3.x=120
            yz4.x=120
            yz_speed=10
        if playground.collide_point(pos):
            state=10
            slaa.x=50
            slab.x=50
        if biu.collide_point(pos):
            state=12
            no.x=5233
            zidan=10
        if rock.collide_point(pos):
            state=14
            panda.x=300
            panda.y=300
            power=100
            onfloor=True
        if ball.collide_point(pos):
            
            state=16
            basketball.x=144
            basketball.y=230
            cifang=5
            score=0
            ikun.x=100
            onhand=True
        if nextl.collide_point(pos):
            state=18
            
        
    elif state==9:
        if win1.collide_point(pos):
            state=7
            
    elif state==11:
        if win2.collide_point(pos):
            state=7
            
    elif state==12:
        if bz.collide_point(pos):
            no.pos=pos
            if zidan>0:
                zidan-=1
            if abs(no.x-bz.x)<10 and abs(no.y-bz.y)<10:
                time.sleep(0.5)
                state=13
                
                win3.frame=0
                jinpai+=1
            if zidan<=0:
                time.sleep(0.5)
                state=13
                win3.frame=1
    elif state==13:
        if win3.collide_point(pos):
            state=7
                 
    elif state==15:
        if win4.collide_point(pos):
            state=7
            
    elif state==17:
        if win5.collide_point(pos):
            state=7
    elif state==18:
        if snowmountain.collide_point(pos):
            state=19     
            twoone.y=random.randint(50,250)
            twoone1.y=random.randint(50,250)
    elif state==20:
        if button.collide_point(pos):
            if bing1.frame==bing2.frame==bing3.frame:
                state=21
            else:
                bing1.frame=random.randint(0,2)
                bing2.frame=random.randint(0,2)
                bing3.frame=random.randint(0,2)
    elif state==21:
        if fanying.collide_point(pos):
            state=22
    elif state==22:
        if choose1.collide_point(pos):
            state=23
            jieju.frame=0
        if choose2.collide_point(pos):
            state=23
            jieju.frame=1
        if choose3.collide_point(pos):
            state=23
            jieju.frame=2
        if choose4.collide_point(pos):
            state=23
            jieju.frame=3
        if choose5.collide_point(pos):
            state=23
            jieju.frame=4
            
def on_key_down(key): 
    global oxy,yz_speed,tili,leave_speed,spaceand,cifang
    global fly,twoone_hp,twoone1_hp
    if state==8:
        if key=="O":
            yz_speed=2
            
            oxy+=50
            if oxy>100:
                oxy=100
            yz_speed=2
            time.sleep(0.3)
            yz_speed=10
        if key=="W":
            if yz.x<520:
                yz.x+=yz_speed
            yz.frame+=1
    elif state==10:
        if key=="S":
            if tili<100:
                tili+=5
            ima_speed=2
            ima_speed=6
        if key=="W":
            if slaa.x<550:
                slaa.x+=lma_speed*(tili**3)/(tili*1300)
            slaa.frame+=1
    elif state==12:
        if key=="O":
            if leave_speed>0:
                leave_speed=0.4
            else:
                leave_speed=-0.4
    elif state==14:
        if key=="A":
            panda.x-=5
        if key=="D":
            panda.x+=5
    elif state==16:
        if key=="SPACE":
            if cifang>0:
                if onhand==True:
                    
                    
                    spaceand+=5
        if key=="W":
            if onhand==True:
                ikun.x+=5
        if key=="S":
            if onhand==True:
                ikun.x-=5    
    elif state==19:
        if key=="SPACE":
            if fly==False:
                hunbupa.x=161
                hunbupa.y=dududa.y-3
                fly=True
                while fly==True:
                    hunbupa.x+=1
                hunbupa.x=5233
        if key=="W":
            if dududa.y>50:
                dududa.y-=5
        if key=="S":
            if dududa.y<250:
                dududa.y+=5
def on_key_up(key):
    global g
    global leave_speed,state,power,onfloor,spaceand,onhand,spacean
    if state==12:
        if key=="O":
            if leave_speed>0:
                leave_speed=1
            else:
                leave_speed=-1
    elif state==14:
        if key=="W":
            if power>20:
                panda.frame=1
                for i in range(8):
                    panda.y-=10
                power=0
                onfloor=False
                time.sleep(0.5)
                panda.frame=0
    elif state==16:
        if key=="SPACE":
            if cifang>0:
                if onhand==True:
                    onhand=False
                    basketball.x=ikun.x+44
                    basketball.y=ikun.y+40
                    if spaceand>1000:
                        spaceand=1000
                    spacean=spaceand/50
                    
                    for rangeing in range(200):
                        if onhand==False:
                            if rangeing==0:
                                g=-10
                            else:
                                g=((65//rangeing)*-1+4-spacean//300) 
                                  
                                basketball.x+=(spacean*4-rangeing//50)
                            time.sleep(0.03)         
                    g=10
                    spaceand=0
        
go()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值