[Pygame combat] The end of the world is coming, a cruel survival game that really starts from scratch, how long can you live

Hits: 0

Introduction

There is a group of people in the world who believe that in their lifetime they will encounter the situations that appear in the doomsday movies.

Such as biochemical disasters, natural disasters, alien invasions, etc.

This group of people has a cool name – “Doomsday Survivalists”

With a spirit of “I believe it anyway”, they plan ahead. Stockpiling a lot of survival supplies is just an introductory lesson.

Building private shelters, devil-style field survival training is their daily routine.

Of course, most people do not deliberately prepare for the end times. But the editor thinks that everyone’s awareness of survival in the apocalypse is still quite strong.

I don’t know if you still remember the salt we robbed in those years?

The complete material + source code of all articles are in 👇👇

**[Fans who prostitute source code benefits, please move to the CSDN community or the public at the end of the article for free.]**

This awareness of preparing for danger in times of peace may be related to the fact that we always come into contact with works on the theme of the end times.

Many well-known movies are apocalyptic backgrounds, such as “The Walking Dead”, “Train to Busan” , etc.

Of course, such a good theme is also indispensable for games, such as the popular H1Z1, the classic “Fallout” series, etc. Today, the editor brings

Excited to make a Python version of the text apocalypse game for everyone!

(The interface version of the apocalypse game is too hair-consuming, and I can’t make it myself. This time it’s a simple text version of the apocalypse.)

text

1. Effect display

The code is packaged directly, the following demo is on the exe file👇

1) The first day of the last days

2) Different selection results are different

3) View character information

Second, the code display

def f():
        global choice,yourobject,choice2,Hp,Hunger,obj1,obj2,obj3,obj4,obj5,obj6,obj7,nun,koo,Def,Atk,uplimit
        while True:
                try:
                        choice=int(input( '\n>>(check character status, return 1; check inventory, return 2):' ))
                         break 
                except :
                        print('error')
        if choice==1:
            print( 'View character status' )
            print( 'Life:' +str(Hp)+ '\n' + 'Hunger:' +str(Hunger)+ '\n' + 'Attack:' +str(Atk)+ '\n' + 'Defense: ' +str(Def))
         if choice== 2 :
            print( 'View inventory' )
            print(sorted(yourobject.values()))
            if sorted(yourobject.values())==[]:
                print( 'The inventory is empty!' )
                koo=1
            else:
                    while True:
                            try:
                                    choice2=int(input( 'Is the item used? (yes: 1; no; 2):' ))
                                    koo=0
                                    break
                            except:
                                    print('error')
            if choice2==1 and koo==0:
                while True:
                        try:
                                nun=int(input( 'Please enter the serial number of the item to be used:' ))
                                 break 
                        except :
                                print('error')
                print( 'You used' +yourobject1[nun])
                 if obj1>= 2  and nun== 1 :
                    obj1-=1
                    Hunger+=80
                    if Hunger>=uphunger:
                            Hunger=uphunger
                            print( '################Hunger has reached the line!' )
                     else :
                            print('Hunger+80')
                    yourobject[ 1 ]=str( 1 )+ 'beef jerky' + '×' +str(obj1)

                elif obj1== 1  and nun== 1 :
                    yourobject.pop(nun)
                    Hunger+=80
                    if Hunger>=uphunger:
                            Hunger=uphunger
                            print( '################Hunger has reached the line!' )
                     else :
                            print('Hunger+80')
                elif obj2>=2 and nun==2:
                    obj2-=1
                    Hp+=50
                    if Hp>=uplimit:
                            Hp=uplimit
                            print( '################HP has reached the limit!' )
                     else :
                            print('Hp:+50')
                    yourobject[ 2 ]=str( 2 )+ 'Wangzai Milk' + '×' +str(obj2)
                 elif obj2== 1  and nun== 2 :
                    yourobject.pop(nun)
                    Hunger+=1
                    Hp+=50
                    if Hp>=uplimit:
                            Hp=uplimit
                            print( '################HP has reached the limit!' )
                     else :
                            print('Hp:+50')
                elif obj3>=2 and nun==3:
                    obj3-=1
                    Atk+=15
                    Hp+=90
                    if Hp>=uplimit:
                            Hp=uplimit
                            print( '###############HP has reached the limit!' )
                            print( 'Attack +15' )
                     else :
                            print( 'Hp:+90\nAttack +15' )
                    yourobject[ 3 ]=str( 3 )+ 'Red Bull' + '×' +str(obj3)
                 elif obj3== 1  and nun== 3 :
                    yourobject.pop(nun)
                    Atk+=15
                    Hp+=90
                    if Hp>uplimit:
                            Hp=uplimit
                            print( '###############HP has reached the limit!' )
                            print( 'Attack +15' )
                     else :
                            print( 'Hp:+90\nAttack+15' )
                 elif obj4>= 2  and nun== 4 :
                    obj4-=1
                    Hunger+=100
                    if Hunger>=uphunger:
                            Hunger=uphunger
                            print( '################Hunger has reached the line!' )
                     else :
                            print('Hunger+100')
                    yourobject[ 4 ]=str( 4 )+ 'canned fish' + '×' +str(obj4)
                 elif obj4== 1  and nun== 4 :
                    yourobject.pop(nun)
                    Hunger+=100
                    if Hunger>=uphunger:
                            Hunger=uphunger
                            print( '################Hunger has reached the line!' )
                     else :
                            print('Hunger+100')
                elif obj5>=2 and nun==5:
                    obj5-= 1 
                    Def+= 10 
                    print( 'Defense+10' )
                    yourobject[ 5 ]=str( 5 )+ 'Jinliduo' + '×' +str(obj5)
                 elif obj5== 1  and nun== 5 :
                    yourobject.pop(nun)
                    Def+= 10 
                    print( 'Defense+10' )
                 elif obj6>= 2  and nun== 6 :
                    obj6-= 1 
                    uplimit+= 300 
                    print( 'Life limit+300' )
                    yourobject[ 6 ]=str( 6 )+ 'Shenbao Piece' + '×' +str(obj6)
                 elif obj6== 1  and nun== 6 :
                    yourobject.pop(nun)
                    uplimit+= 300 
                    print( 'Life limit+300' )
                 elif obj7>= 2  and nun== 7 :
                    obj7-= 1 
                    Atk+= 1 
                    Def+= 1 
                    print( 'Attack+1\nDefense+1' )
                    yourobject[ 7 ]=str( 7 )+ 'skittles' + '×' +str(obj7)
                 elif obj7== 1  and nun== 7 :
                    yourobject.pop(nun)
                    Atk+= 1 
                    Def+= 1 
                    print( 'Attack+1\nDefense+1' )
         if choice== 2019 :
            print( 'Get a kidney tablet!!!' )
            name= 'Shenbao tablet'
            q()
            obj6+=1
            yourobject[6]=str(6 )+name+'×'+str(obj6)
            yourobject1[6]=name
        elif choice==520:
            Atk+=200
        elif choice==1314:
            Def+=50
def g():
    global time,choice1
    while True:
        try:
                print( '\nNow it's {}, what should you do?\n>>1. Search for supplies; 2. Open the menu bar; 3. Trim in the shelter' .format(timedic[time]))
                choice1=int(input( '>>Your choice is (input 1 or 2 or 3)?:' ))
                 break 
        except :
                print( 'error' )
 def  t () : 
        enter=input( '(enter to continue the game)' )
         if enter== '' :
                 pass 
def  t1 () : 
        enter=input( '(enter to continue the fight!)\n' )
         if enter== '' :
                print('\n'+'*'*50)
def w():
    global Hp,die,tap
    ff=randint(0,50)
    if ff==12 or ff==5 or ff==28 or ff==44:
        print( '\nOops!\nThere is a zombie boss!!!' )
        Hp-= 50 
        print( 'After the battle, you lost 50 HP\n-50Hp' )
     elif   tap== 1 :
        print( 'You encountered a corpse tide!!!' )
        Hp-= 300 
        print( 'Heavy hit!!!\nHp-300' )
        die=1
    elif ff>30 and ff<40:
        print( '\nOops!\nThere are normal zombies!!!' )
        Hp-= 10 
        print( 'After the battle, you lost 10 HP\n-10Hp' )
     else :
        print( '\nYou didn't alert the zombies.\n' )
 def  w1 () : 
        global monster,Hp,Hp1
        print( '{} found you!!!\nYou will face a tough fight!' .format(monster))
        t()
        while Hp>0 and Hp1>0:
                first=randint(0,1)
                if first==0:
                        print( '>>{} round!\n' .format(monster))
                        w2()
                        t1()
                elif first==1:
                        print( '>>Your turn!\n' )
                        w3()
                        t1()
def w2():
        global Atk1,Def,Hp,Hp1
        mon1=randint( 1 , 10 )
         if mon1== 1 :
                 if Atk1<=Def:
                        print('miss')
                else:
                        Hp-=(Atk1-Def)
                        print( '>{} Raises the bloody claws and strikes! {}HP: {}\n Your HP: {}\n***Inflicted {} damage to you!' . format(monster,monster,Hp1,Hp,Atk1-Def))
         else :
                 if Atk1<= 3 *Def:
                        print('miss')
                else:
                        Hp-=(Atk1-3*Def)
                        print( '>{} raised his hand and made a normal attack! {}'s HP: {}\n Your HP: {}\n*** caused {} damage to you!' .format(monster,monster, Hp1,Hp,Atk1 -3 *Def))
 def  w3 () : 
        global monster,Atk,Def1,Hp1,Hp
        you=randint(1,10)
        if you==1:
                if 2*Atk<=Def1:
                        print('miss')
                else:
                        Hp1-=( 2 *Atk-Def1)
                        print( '>You hit a deadly blow!!! {}'s HP: {}\n Your HP: {}\n*** Dealed {} damage to {}!!!' .format(monster ,Hp1,Hp,monster, 2 *Atk-Def1))
         else :
                 if Atk<=Def1:
                        print('miss')
                else:
                        Hp1-=(Atk-Def1)
                        print( '>You hit a normal attack! {}'s HP: {}\n Your HP: {}\n*** caused {} damage to {}!!!' .format(monster,Hp1, Hp,monster,Atk-Def1))




def h():
    global obj1,obj2,name,obj3,obj4,obj5,obj6,obj7
    print( 'Start searching!' )
    obj=randint(1,40)
    if obj==1 or obj==4 or obj==7:
        name= 'Beef Jerky'
        q()
        obj1+=1
        yourobject[1]=str(1 )+name+'×'+str(obj1)
        yourobject1[1]=name
    elif obj==14 or obj==17 or obj==20 or obj==21:
        name= 'Wangzai Milk'
        q()
        obj2+=1
        yourobject[2]=str(2 )+name+'×'+str(obj2)
        yourobject1[2]=name
    elif obj==2 or obj==8 or obj==13:
        name= 'Red Bull'
        q()
        obj3+=1
        yourobject[3]=str(3 )+name+'×'+str(obj3)
        yourobject1[3]=name
    elif obj==24 or obj==11 or obj==10:
        name= 'Canned fish'
        q()
        obj4+=1
        yourobject[4]=str(4 )+name+'×'+str(obj4)
        yourobject1[4]=name
    elif obj==5 or obj==15:
        name= 'Jianliduo'
        q()
        obj5+=1
        yourobject[5]=str(5 )+name+'×'+str(obj5)
        yourobject1[5]=name
    elif obj==9:
        name= 'Shenbao tablet'
        q()
        obj6+=1
        yourobject[6]=str(6 )+name+'×'+str(obj6)
        yourobject1[6]=name
    elif obj==40 or obj==33 or obj==35 or obj==37:
        name= 'skittle candy'
        q()
        obj7+=1
        yourobject[7]=str(7 )+name+'×'+str(obj7)
        yourobject1[7]=name

    else:
        print( 'You didn't find anything!' )
        t()
def q():
    global name
    print( 'Congratulations, got' +name)
    t()

yourobject={}
yourobject1={}
obj1=0
obj2=0
obj3=0
obj4=0
obj5=0
obj6=0
obj7=0
Hp=250
uplimit=250
Hp1=550
Hunger=300
uphunger=300
Day=0
time=1
choice1=0
name=''
name2=''
a=''
monster=''
choice2=100
koo=0
tap=0
Atk=22
Atk1=70
Def=10
Def1= 20 
die= 0 
timedic={ 1 : '6 am' , 2 : '12 noon' , 3 : '2 pm' , 4 : '6 pm' , 5 : '12 midnight' }
 from random import *
 while Hp> 0 :
    Day+= 1 
    time= 1 
    tap= 0 
    print( '\n>>You were woken up by the roar of zombies outside the shelter, you lived to the {}th day! ######' .format(Day))
     if Day== 1 :
        print( 'On the first day of the apocalypse, the whole city was attacked by zombies, the traffic was paralyzed, and the electricity was damaged.\n At 6:00 in the morning, you felt lost and helpless in the face of everything that came suddenly.' )
     elif Day == 7 :
        print( '\nThe situation seems to be getting worse!\n' )
        t()
        monster= '[The Bomber]'
        w1()
        if Hp<=0:
                print( 'You are dead!' )
                 break 
        elif Hp1<= 0 :
                print( '{} is dead!'. format(monster))
                print( '\n>>>>Get a kidney tablet!!!' )
                name= 'Shenbao tablet'
                q()
                obj6+=1
                yourobject[6]=str(6 )+name+'×'+str(obj6)
                yourobject1[6]=name
    elif Day==22:
        print( '\nYou are not sure if there are still people alive!\n' )
        t()
        monster= '【Dead King】' 
        Hp1+= 3000 
        Atk1+= 200 
        Def1+= 50
        w1()
        if Hp<=0:
                print( 'You are dead!' )
                 break 
        elif Hp1<= 0 :
                print( '{} is dead!'. format(monster))
                print( '\n>>>>Get a kidney tablet!!!' )
                name= 'Shenbao tablet'
                q()
                obj6+=1
                yourobject[6]=str(6 )+name+'×'+str(obj6)
                yourobject1[6]=name
    t()
    while time<=5:
        g()
        if choice1==1:
                time+= 1 
                Hunger-= 10 
                print( '\nHunger makes you sluggish! Hunger-10\n' )
                h()
                if time==6:
                        tap=1
                w()
                if die==1 and Hp<=0:
                        print( 'You died in the corpse tide!' )
                         break 
        elif choice1== 2 :
                time=time
                f()
        elif choice1==3:
                time+=1
                Hp+=30
                if Hp>=uplimit:
                            Hp=uplimit
                            print( '################HP has reached the limit! No need to rest!' )
                 else :
                            print('Hp:+30')

    if Hunger<=0:
        Hp+=Hunger
        print( 'Hunger drives you crazy!\nYou lost {}Hp\n-{}Hp' .format(abs(Hunger),abs(Hunger)))
print('gameover')
input('123:')


Doomsday survival games have always had an irresistible romance.

Compared with other open world games, the unique charm of the doomsday background lies in the most essential issue of “survival”.

We are not for anyone or anything, or to save the world, we are just to survive, that’s all.

In the familiar and unfamiliar urban ruins, under the apocalypse that cannot be far away, this sense of substitution makes the heart beat faster.

So the editor thinks that doomsday survivalists who “prepare for a rainy day and save themselves when a crisis comes” are definitely not mentally ill.

Not only that, but many people also think this is cool and yearn for those expensive and reliable tools and materials. In fact, such people

It can also be understood as similar to military enthusiasts or collectors. Of course, it is not a bad phenomenon. Instead, as a niche

Phenomenon, doomsday survivalism was quickly integrated into cultural works represented by games.

Nowadays, this element is more or less added in many games, and obviously many players (including Xiaobian and me) like this kind of

“It looks cool” stuff. An orthodox post-apocalyptic survival game is now rare.

This kind of attempt is indeed worthy of encouragement, so everyone quickly come to me to experience the source code! Click 👇 to enter the game and

Let’s survive the doomsday together!

Interactive topic: If the end of the world comes, you can only bring three items, what would you bring?

🎯Complete free source code collection: find me! You can get it by yourself at the end of the article, and I can too!

🔨Recommend previous articles——

Project 1.0 Bubble Machine Game

[Pygame actual combat] A super interesting bubble game is coming – I hope your childlike innocence is not lost, and you will always be happy and simple~

Project 8.1 “Basketball “Prince” mini game

[Pygame actual combat] Interesting basketball – welcome the “basket”, enjoy the “ball”, and the little cutie who likes to play basketball will come to report~

Project 7.3 Want to kill the virus and defend the city” game

[[Pygame actual combat] During the epidemic, I recommend a cool game “Eliminate the virus and defend the city” for those who can’t go out. [Strong recommendation] May it end soon]

Project 5.8 Flop Mini Game

Pygame combat: what to do with poor memory? Don’t worry, the memory-enhancing mini-game is for you~【The more you play, the more addictive】

Item 5.3 “One Two Three Wooden Man” mini game of “Squid Game”

When “Squid Game” hits strongly: “One, two, three, wooden man, Smecta.” Are you still afraid?

🎄Article Summary——

Project 1.0  Python—2021 |Summary of existing articles | Continuously updated, just read this article

(More content + source code are summarized in the article!! Welcome to read~)

You may also like...

Leave a Reply

Your email address will not be published.