Python-implemented simple RPG-game process examples

Source: Internet
Author: User
The example in this paper describes the simple RPG game flow implemented by Python. Share to everyone for your reference. Specific as follows:

#RPGrpg = truewhp = 100MAHP = 100hhp = 100MHP = 10def dgrnd (): WA = raw_input ("What does Warrior does?") Ma = raw_input ( "What does Mage does?")  Ha = Raw_input ("What does healer does?") if WA = = "Flame Slash": Print ("Warrior uses 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 ' s attack did no damage!") if Ma = = "Icicle D ROP ": 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-50 If ha = = "Heal Warrior": Print ("Healer heals warrior!")  WHP + If ha = = "Heal Mage": Print ("Healer heals mage!")  MAHP + 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 have" +whp+ "HP left, Mage have" +mahp+ "HP left, and healer have" +hhp+ "HP left!") if  MHP = = 0:print ("You defeated the" +m+ "!") Print ("That's all I had built so far.  Eventually, there'll be more! ")  Print ("Thank for playing!!") Dgrnd () if RPG = = True:print ("This mode isn't yet complete. It is 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 is thr EE passages. Do I take the first one, the second one, or the third one? ") if rm = = ' One ': M = ' Troll ' MHP = Print ("A" +m+ "appears!") if rm = = ' One ': M = ' Goblin ' MHP = print ("a" + m+ "appears!") if rm = = ' three ': M = ' Dragon ' MHP = + print ("A" +m+ "appears!") while MHP > 0:dgrnd ()

Hopefully this article will help you with Python programming.

  • 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.