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程序设计有所帮助。