Python implementation of simple RPG game process example

Source: Internet
Author: User


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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.