python实现的简单RPG游戏流程实例
本文实例讲述了python实现的简单RPG游戏流程。分享给大家供大家参考。具体如下:
#RPG
rpg=True
whp=100
mahp=100
hhp=100
MHP=10
defdgrnd():
wa=raw_input("WhatdoesWarriordo?")
ma=raw_input("WhatdoesMagedo?")
ha=raw_input("WhatdoesHealerdo?")
ifwa=="flameslash":
print("WarriorusesFlameSlash!")
MHP-20
elifwa=="DragonSlash"andM=="Dragon":
print("WarriorusedDragonSlash!")
MHP-80
ifwa=="Dragon"andM=="Troll"orM=="Goblin":
print("Warrior'sattackdidnodamage!")
ifma=="icicledrop":
print("MageusedIcicleDrop")
MHP-15
mahp-10
whp-10
hhp-10
ifma=="flamesofheck":
MHP-75
mahp-50
wph-50
hhp-50
ifha=="healwarrior":
print("HealerHealsWarrior!")
whp+20
ifha=="healmage":
print("HealerHealsMage!")
mahp+20
ifha=="healhealer":
print("HealerHealsHealer!")
hhp+20
ifha=="attack":
print("HealerAttacks!")
MHP-5
print(M+"attacks!")
ifM=="dragon":
whp-40
mahp-40
hhp-40
ifM=="Troll":
whp-30
mahp-30
hhp-30
ifM=="Goblin":
whp-20
mahp-20
hhp-20
print("Warriorhas"+whp+"HPleft,Magehas"+mahp+"HPleft,andHealerhas"+hhp+"HPleft!")
ifMHP==0:
print("Youdefeatedthe"+M+"!")
print("ThatisallIhavebuiltsofar.Eventually,therewillbemore!")
print("ThankYouforPlaying!!")
dgrnd()
ifrpg==True:
print("Thismodeisnotyetcomplete.Itonlycontainsadungeonsofar.I'mstillworkingontherest.")
#Dungeon
whp=100
mahp=100
hhp=100
MHP=10
M="fail"
print("Youenterthedungeon")
rm=raw_input("Therearethreepassages.Doyoutakethefirstone,thesecondone,orthethirdone?")
ifrm=='one':
M='Troll'
MHP=80
print("A"+M+"appears!")
ifrm=='two':
M='Goblin'
MHP=35
print("A"+M+"appears!")
ifrm=='three':
M='Dragon'
MHP=120
print("A"+M+"appears!")
whileMHP>0:
dgrnd()
希望本文所述对大家的Python程序设计有所帮助。
热门推荐
10 诗词送行祝福语大全简短
11 新房开工吉日祝福语简短
12 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短