当前位置:网站首页>[pyGame practice] when the end of the world comes, how long can you live in a cruel survival game that really starts from scratch?
[pyGame practice] when the end of the world comes, how long can you live in a cruel survival game that really starts from scratch?
2022-07-28 11:44:00 【Gu Muzi acridine】
Introduction
There are so many people in the world , They believe that they will encounter those situations in the doomsday movie in their lifetime .
Such as biochemical disaster 、 Natural disasters 、 Alien invasion and so on .
These people have a cool name ——“ Doomsday survivalist ”
They rely on one “ I believe it anyway ” The spirit of , Save against a rainy day . Storing a lot of survival supplies is just an introductory course .

Build private shelters , Devil's wild survival training is their daily .

Of course , Most people don't deliberately prepare for the end of the world . But Xiaobian thinks , Everyone's sense of survival at the end of the world is still very strong .
I don't know if you still remember the salt we robbed in those years ?
Complete material for all articles + The source code is in

This sense of being prepared for danger in times of peace , Maybe it's related to the fact that we always come into contact with works with eschatological themes .
Many famous movies have eschatological backgrounds , for example 《 A dead-alive person 》《 Busan trip 》 wait
Of course, such a good theme can't do without games , All the rage H1Z1, classical 《 radiation 》 Series and so on , Today Xiaobian took
Warm blooded excitement also gives everyone Make a Python Version of the text doomsday game Ba !
( The interface version of the apocalyptic game is too hair consuming , I can't do it myself , This is a simple text apocalyptic version .)
Text
One 、 Effect display
The code is packaged directly , The following demonstration is in exe On the file

1) The first day of the Apocalypse

2) Different choices lead to different results

3) View people information

Two 、 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 the item list , return 2):'))
break
except:
print('error')
if choice==1:
print(' Check character status ')
print(' life :'+str(Hp)+'\n'+' hunger :'+str(Hunger)+'\n'+' attack :'+str(Atk)+'\n'+' defense :'+str(Def))
if choice==2:
print(' Check the item list ')
print(sorted(yourobject.values()))
if sorted(yourobject.values())==[]:
print(' Item column is empty !')
koo=1
else:
while True:
try:
choice2=int(input(' Whether to use items ?( 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 have used it. '+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 )+' Dried beef '+'×'+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('############### Your HP has reached the upper limit !')
else:
print('Hp:+50')
yourobject[2]=str(2 )+' Want Want Children's milk '+'×'+str(obj2)
elif obj2==1 and nun==2:
yourobject.pop(nun)
Hunger+=1
Hp+=50
if Hp>=uplimit:
Hp=uplimit
print('############### Your HP has reached the upper limit !')
else:
print('Hp:+50')
elif obj3>=2 and nun==3:
obj3-=1
Atk+=15
Hp+=90
if Hp>=uplimit:
Hp=uplimit
print('############### Your HP has reached the upper limit !')
print(' attack +15')
else:
print('Hp:+90\n attack +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('############### Your HP has reached the upper limit !')
print(' attack +15')
else:
print('Hp:+90\n attack +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 )+' Jianlido '+'×'+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 tablets '+'×'+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\n defense +1')
yourobject[7]=str(7 )+' Rainbow sugar '+'×'+str(obj7)
elif obj7==1 and nun==7:
yourobject.pop(nun)
Atk+=1
Def+=1
print(' attack +1\n defense +1')
if choice==2019:
print(' Get a kidney tablet !!!')
name=' Shenbao tablets '
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('\n Now it is {}, How should you act ?\n>>1. Search for supplies ;2. Open the menu bar ;3. Repair 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 Keep playing )')
if enter=='':
pass
def t1():
enter=input('(enter Keep fighting !)\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('\n too bad !\n There are zombie leaders !!!')
Hp-=50
print(' After fighting , You lost 50 spot HP\n-50Hp')
elif tap==1:
print(' You have encountered a wave of corpses !!!')
Hp-=300
print(' Be badly hurt !!!\nHp-300')
die=1
elif ff>30 and ff<40:
print('\n too bad !\n There are ordinary zombies !!!')
Hp-=10
print(' After fighting , You lost 10 spot HP\n-10Hp')
else:
print('\n You didn't disturb the zombie .\n')
def w1():
global monster,Hp,Hp1
print('{} Found you !!!\n You will face a bitter battle !'.format(monster))
t()
while Hp>0 and Hp1>0:
first=randint(0,1)
if first==0:
print('>>{} The round of !\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('>{} Raised the bloody claw , A heavy blow ! {} Of HP:{}\n Yours HP:{}\n*** It has caused you {} Point injury !'.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 common attack ! {} Of HP:{}\n Yours HP:{}\n*** It has caused you {} Point injury !'.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 fatal blow !!! {} Of HP:{}\n Yours HP:{}\n*** Yes {} It's caused {} Point injury !!!'.format(monster,Hp1,Hp,monster,2*Atk-Def1))
else:
if Atk<=Def1:
print('miss')
else:
Hp1-=(Atk-Def1)
print('> You hit a normal attack ! {} Of HP:{}\n Yours HP:{}\n*** Yes {} It's caused {} Point injury !!!'.format(monster,Hp1,Hp,monster,Atk-Def1))
def h():
global obj1,obj2,name,obj3,obj4,obj5,obj6,obj7
print(' Begin your search !')
obj=randint(1,40)
if obj==1 or obj==4 or obj==7:
name=' Dried beef '
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=' Want Want Children's 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=' Jianlido '
q()
obj5+=1
yourobject[5]=str(5 )+name+'×'+str(obj5)
yourobject1[5]=name
elif obj==9:
name=' Shenbao tablets '
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=' Rainbow sugar '
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 , To obtain the '+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:' Early in the morning 6 spot ',2:' At noon, 12 spot ',3:' Afternoon 2 spot ',4:' In the evening 6 spot ',5:' The middle of the night 12 spot '}
from random import*
while Hp>0:
Day+=1
time=1
tap=0
print('\n>> You were awakened by the roar of zombies outside the shelter , You live to the th {} God !######'.format(Day))
if Day==1:
print(' The first day of the Apocalypse , The whole city was attacked by zombies , Traffic is paralyzed , Power damage .\n Early in the morning 6 spot , Facing all the sudden , You feel confused and helpless .')
elif Day==7:
print('\n Things seem to be getting worse !\n')
t()
monster='【䘮 Exploder 】'
w1()
if Hp<=0:
print(' You're dead !')
break
elif Hp1<=0:
print('{} Already dead !'.format(monster))
print('\n>>>> Get a kidney tablet !!!')
name=' Shenbao tablets '
q()
obj6+=1
yourobject[6]=str(6 )+name+'×'+str(obj6)
yourobject1[6]=name
elif Day==22:
print('\n You are not sure if there are still living people !\n')
t()
monster='【 undying 】'
Hp1+=3000
Atk1+=200
Def1+=50
w1()
if Hp<=0:
print(' You're dead !')
break
elif Hp1<=0:
print('{} Already dead !'.format(monster))
print('\n>>>> Get a kidney tablet !!!')
name=' Shenbao tablets '
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('\n Hunger slows you down ! Hunger-10\n')
h()
if time==6:
tap=1
w()
if die==1 and Hp<=0:
print(' You die in the tide of corpses !')
break
elif choice1==2:
time=time
f()
elif choice1==3:
time+=1
Hp+=30
if Hp>=uplimit:
Hp=uplimit
print('############### Your HP has reached the upper limit ! No need to rest !')
else:
print('Hp:+30')
if Hunger<=0:
Hp+=Hunger
print(' Hunger drives you crazy !\n You lost {} spot Hp\n-{}Hp'.format(abs(Hunger),abs(Hunger)))
print('gameover')
input('123:')
summary
Doomsday survival games always have a kind of romance that people can't refuse .
Compared with other open world games , The unique charm of the doomsday background lies in “ Existence ” This is the most essential problem .
We are not for someone or something , Or save the world , We just want to live , That's it .
In the familiar and strange urban ruins , Under the endless doomsday , This sense of substitution makes the heart beat faster .

So Xiaobian thinks “ Save against a rainy day , Save yourself when the crisis comes ” Doomsday survivalists are definitely not psychotic .
More Than This , Many people still think it's cool , Yearn for those expensive and reliable tools and materials . This kind of people actually
It can also be understood as a military enthusiast or collector , Of course , Nor is it a bad phenomenon . On the contrary, as a minority
The phenomenon , Doomsday survivalism is quickly integrated into cultural works represented by Games .
Nowadays, this element is more or less added to many games , Obviously, many players ( Including Xiaobian me ) I really like this
“ It looks cool ” Of course . An orthodox game of eschatological survival , Now it's rare .
This kind of attempt is really worth encouraging , So come to me to get the source code and experience it ! Click on , Enter the game and
Xiaobian, let's survive the doomsday !
Interactive topics : If the end comes , You can only bring three items , What will you bring ?
Complete free source code collection office : Find me ! At the end of the article, you can get it by yourself , Didi, I can also !
I recommend previous articles ——
project 1.0 Bubble machine games
project 8.1 《 Basketball “ prince ”》 Little games
project 7.3 Want to kill the virus and defend the city 》 game
project 5.8 Flop games
project 5.3 《 Squid game 》 And 《 One, two, three wooden people 》 Little games
A summary of the article ——
project 1.0 Python—2021 | Summary of existing articles | Continuous updating , Just read this article directly
( More + The source code is summarized in the article !! Welcome to ~)

边栏推荐
- 抖音程序员表白专用代码教程(如何玩抖音)
- Four advantages of verification code to ensure mailbox security
- How to effectively implement a rapid and reasonable safety evacuation system in hospitals
- 数字孪生轨道交通:“智慧化”监控疏通城市运行痛点
- Two point, three point, 01 point plan [bullet III]
- STM32 drives st7701s chip (V ⅰ V0 mobile phone screen change price)
- Top ten application development trends from 2022 to 2023
- Design a system that supports millions of users
- What kind of knowledge payment system functions are more conducive to the development of the platform and lecturers?
- R语言-用于非平衡数据集的一些度量指标
猜你喜欢

Solutions to the disappearance of Jupiter, spyder, Anaconda prompt and navigator shortcut keys

LabVIEW AI视觉工具包(非NI Vision)下载与安装教程

Three methods of using unity mouse to drive objects

保障邮箱安全,验证码四个优势

使用 Terraform 在 AWS 上快速部署 MQTT 集群

AlexNet—论文分析及复现

ripro9.0修正升级版+WP两款美化包+稀有插件
![[general database integrated development environment] Shanghai daoning provides you with Aqua Data Studio downloads, tutorials, and trials](/img/46/830b7703ae7cbfa6051137061560c2.png)
[general database integrated development environment] Shanghai daoning provides you with Aqua Data Studio downloads, tutorials, and trials

What functions does MySQL have? Don't look everywhere. Just look at this.

A hundred flowers bloom in data analysis engines. Why invest heavily in Clickhouse?
随机推荐
在生产环境中每天Oracle监控到的无效对象一般怎么去处理?
服务器在线测速系统源码
PKG packaging node project
Design a system that supports millions of users
ZBrush 2022 software installation package download and installation tutorial
[half understood] zero value copy
Database advanced learning notes -- object type
【Gradle】This version of the JMH Gradle plugin requires Gradle 6+, you are using 6.6.
Database advanced learning notes - storage structure
Unity鼠标带动物体运动的三种方法
Cvpr2021 pedestrian re identification /person re identification paper + summary of open source code
「以云为核,无感极速」第五代验证码重磅来袭
Object stream of i/o operation (serialization and deserialization)
Design and implementation of SSM personal blog system
Installing sqlmap on win10 (Windows 7)
R language ggplot2 visualization: use the ggboxplot function of ggpubr package to visualize the box diagram and customize the fill parameter to configure the filling color of the box
Are interviews all about memorizing answers?
Five Ali technical experts have been offered. How many interview questions can you answer
使用c语言实现双向链表
Good use explosion! The idea version of postman has been released, and its functions are really powerful