This example describes the simple RPG game process that Python implements. Share to everyone for your reference. Specifically as follows:
|
#RPG RPG = True whp = MAHP = HHP = MHP = Ten def dgrnd (): WA = raw_input ( "What does Warrior do") Ma = raw_input ("What does Mage do") ha = Raw_input ("What does does?") if WA = = "Healer Flame": Print ("Slash use s Flame slash! ") MHP-20 elif wa = = "Dragon slash" and M = = "Dragon": Print ("Warrior used Dragon slash!") MHP-80 if wa = = "Dragon" and M = = "troll" or M = = "Goblin": Print ("Warrior ' attack did no damage!") if Ma = = "Icicle Dr OP: Print ("Mage used Icicle Drop") MHP-15 mahp-10 whp-10 hhp-10 If ma = = "Flames of Heck": MHP-75 mahp-50 wph-50 hhp-5 0 if ha = = "Heal Warrior": Print ("Healer heals warrior!") whp + if ha = = "Heal Mage": Print (Healer heals mage!) m AHP + If ha = = "Heal Healer": Print ("Healer heals healer!") hhp + if ha = = "Attack": Print ("Healer attacks!") MHP-5 print (m+ "attacks!") if m = = "Dragon": whp-40 mahp-40 hhp-40 if m = = "troll": whp-30 mahp-30 hhp-30 if m = = "Goblin" : whp-20 mahp-20 hhp-20 print ("Warrior has" +whp+ "HP left, Mage has" +mahp+ "HP left, and healer has" +hhp+ "hp le Ft! ") if MHP = = 0:print ("You defeated the" +m+ "!") print ("This is all I have built so far." Eventually, there'll be more! ") Print ("Thank for playing!!") dgrnd () if RPG = = True:print (' This ' is ' not yet complete. It only contains a dungeon so far. I ' m still working on the rest. #Dungeon whp = MAHP = HHP = MHP = Ten M = "fail" Print ("You enter the Dungeon") RM = Raw_input ("There are THR EE passages. Do you take the one, the second one, or the third one? if rm = = ' One ': M = ' troll ' MHP = ms ("a" +m+ "appears!") if RM = = ' two ': M = ' Goblin ' MHP = print (' A ' +m+ ' AP Pears! ") if rm = = ' three ': M = ' Dragon ' MHP = Print ("A" +m+ "appears!") while MHP > 0:dgrnd () |
I hope this article will help you with your Python programming.