python实现的简单RPG游戏流程实例


Posted in Python onJune 28, 2015

本文实例讲述了python实现的简单RPG游戏流程。分享给大家供大家参考。具体如下:

#RPG
rpg = True
whp = 100
mahp = 100
hhp = 100
MHP = 10
def dgrnd () :
 wa = raw_input ("What does Warrior do?")
 ma = raw_input ("What does Mage do?")
 ha = raw_input ("What does Healer do?")
 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 drop" :
  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 + 20
 if ha == "heal mage" :
  print ("Healer Heals Mage!")
  mahp + 20
 if ha == "heal healer" :
  print ("Healer Heals Healer!")
  hhp + 20
 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 left!")
 if MHP == 0 :
  print ("You defeated the "+M+" !")
  print ("That is all I have built so far. Eventually, there will be more!")
  print ("Thank You for Playing!!")
  dgrnd ()
if rpg == True :
 print ("This mode is not yet complete. It only contains a dungeon so far. I'm still working on the rest.")
#Dungeon
 whp = 100
 mahp = 100
 hhp = 100
 MHP = 10
 M = "fail"
 print ("You enter the dungeon")
 rm = raw_input ("There are three passages. Do you take the first one, the second one, or the third one?")
 if rm == 'one' :
  M = 'Troll'
  MHP = 80
  print ("A "+M+" appears!")
 if rm == 'two' :
  M = 'Goblin'
  MHP = 35
  print ("A "+M+" appears!")
 if rm == 'three' :
  M = 'Dragon'
  MHP = 120
  print ("A "+M+" appears!")
 while MHP > 0 :
  dgrnd ()

希望本文所述对大家的Python程序设计有所帮助。

Python 相关文章推荐
Python Web服务器Tornado使用小结
May 06 Python
Python获取邮件地址的方法
Jul 10 Python
Python中.py文件打包成exe可执行文件详解
Mar 22 Python
Python实现的调用C语言函数功能简单实例
Mar 13 Python
Pyqt清空某一个QTreeewidgetItem下的所有分支方法
Jun 17 Python
Python企业编码生成系统之主程序模块设计详解
Jul 26 Python
基于Django静态资源部署404的解决方法
Jul 28 Python
Python实现word2Vec model过程解析
Dec 16 Python
如何使用pandas读取txt文件中指定的列(有无标题)
Mar 05 Python
Python使用xlrd实现读取合并单元格
Jul 09 Python
python如何调用百度识图api
Sep 29 Python
Python中time标准库的使用教程
Apr 13 Python
python实现自动登录人人网并采集信息的方法
Jun 28 #Python
Python实现将绝对URL替换成相对URL的方法
Jun 28 #Python
python实现将html表格转换成CSV文件的方法
Jun 28 #Python
python实现根据主机名字获得所有ip地址的方法
Jun 28 #Python
python自动zip压缩目录的方法
Jun 28 #Python
python查找指定具有相同内容文件的方法
Jun 28 #Python
python中getaddrinfo()基本用法实例分析
Jun 28 #Python
You might like
php缓存技术详细总结
2013/08/07 PHP
PHP可变变量学习小结
2015/11/29 PHP
php使用文本统计访问量的方法
2016/05/12 PHP
php微信公众平台开发(三)订阅事件处理
2016/12/06 PHP
如何解决PHP获取不到SESSION信息之一般情况
2019/10/10 PHP
Jquery实战_读书笔记1—选择jQuery
2010/01/22 Javascript
jquery 多行滚动代码(附详细解释)
2010/06/17 Javascript
JavaScript中number转换成string介绍
2014/12/31 Javascript
小议JavaScript中Generator和Iterator的使用
2015/07/29 Javascript
在js中实现邮箱格式的验证方法(推荐)
2016/10/24 Javascript
js实时获取窗口大小变化的实例代码
2016/11/18 Javascript
JS字符串统计操作示例【遍历,截取,输出,计算】
2017/03/27 Javascript
Bootstrap Tree View简单而优雅的树结构组件实例解析
2017/06/15 Javascript
微信小程序开发之左右分栏效果的实例代码
2019/05/20 Javascript
微信小程序实现卡片层叠滑动效果
2019/06/21 Javascript
0基础学习前端开发的一些建议
2020/07/14 Javascript
解决vue自定义指令导致的内存泄漏问题
2020/08/04 Javascript
[55:11]完美世界DOTA2联赛PWL S2 SZ vs LBZS 第一场 11.26
2020/11/30 DOTA
Python读取图片属性信息的实现方法
2016/09/11 Python
Python编程实现的简单Web服务器示例
2017/06/22 Python
python中如何使用正则表达式的集合字符示例
2017/10/09 Python
Python实现的基数排序算法原理与用法实例分析
2017/11/23 Python
python逆序打印各位数字的方法
2018/06/25 Python
python将.ppm格式图片转换成.jpg格式文件的方法
2018/10/27 Python
python实现动态创建类的方法分析
2019/06/25 Python
keras中的backend.clip用法
2020/05/22 Python
python读取图像矩阵文件并转换为向量实例
2020/06/18 Python
Html5 postMessage实现跨域消息传递
2016/03/11 HTML / CSS
请说出以下代码输出什么
2013/08/30 面试题
党校个人自我鉴定范文
2014/03/28 职场文书
分公司任命书
2014/06/06 职场文书
社区关爱留守儿童活动方案
2014/08/22 职场文书
个人剖析材料范文
2014/09/30 职场文书
2014年旅游局法制宣传日活动总结
2014/11/01 职场文书
营销计划书
2015/01/17 职场文书
Redis实现短信验证码登录的示例代码
2022/06/14 Redis