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基于pygame实现的font游戏字体(附源码)
Nov 11 Python
详解python之简单主机批量管理工具
Jan 27 Python
python3之微信文章爬虫实例讲解
Jul 12 Python
python爬虫之BeautifulSoup 使用select方法详解
Oct 23 Python
对变量赋值的理解--Pyton中让两个值互换的实现方法
Nov 29 Python
Python一句代码实现找出所有水仙花数的方法
Nov 13 Python
Python面向对象之Web静态服务器
Sep 03 Python
Python利用PyExecJS库执行JS函数的案例分析
Dec 18 Python
pandas DataFrame 数据选取,修改,切片的实现
Apr 24 Python
Win10下用Anaconda安装TensorFlow(图文教程)
Jun 18 Python
python爬虫scrapy基于CrawlSpider类的全站数据爬取示例解析
Feb 20 Python
详解解Django 多对多表关系的三种创建方式
Aug 23 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
图形数字验证代码
2006/10/09 PHP
php操作redis缓存方法分享
2015/06/03 PHP
YII2框架中使用yii.js实现的post请求
2017/04/09 PHP
详解PHP中mb_strpos的使用
2018/02/04 PHP
Yii2语言国际化的配置教程
2018/08/19 PHP
动态表格Table类的实现
2009/08/26 Javascript
javascript使用正则表达式检测IP地址
2014/12/03 Javascript
jquery复选框多选赋值给文本框的方法
2015/01/27 Javascript
javascript中的Function.prototye.bind
2015/06/25 Javascript
设置jQueryUI DatePicker默认语言为中文
2016/06/04 Javascript
js简单实现图片延迟加载的方法
2016/07/19 Javascript
JavaScript prototype属性详解
2016/10/25 Javascript
在Vue 中使用Typescript的示例代码
2018/09/10 Javascript
微信小程序实现录制、试听、上传音频功能(带波形图)
2020/02/27 Javascript
解决echarts 一条柱状图显示两个值,类似进度条的问题
2020/07/20 Javascript
如何在vue中使用kindeditor富文本编辑器
2020/12/19 Vue.js
[01:05:56]Liquid vs VP Supermajor决赛 BO 第二场 6.10
2018/07/04 DOTA
python 示例分享---逻辑推理编程解决八皇后
2014/07/20 Python
Python常见格式化字符串方法小结【百分号与format方法】
2016/09/18 Python
快速排序的四种python实现(推荐)
2019/04/03 Python
python使用Qt界面以及逻辑实现方法
2019/07/10 Python
python matplotlib画盒图、子图解决坐标轴标签重叠的问题
2020/01/19 Python
如何使用python切换hosts文件
2020/04/29 Python
Manjaro、pip、conda更换国内源的方法
2020/11/17 Python
地图可视化神器kepler.gl python接口的使用方法
2020/12/22 Python
Pandas数据分析的一些常用小技巧
2021/02/07 Python
一款纯css3实现简单的checkbox复选框和radio单选框
2014/11/05 HTML / CSS
CSS3实现水平居中、垂直居中、水平垂直居中的实例代码
2020/02/27 HTML / CSS
城野医生官方海外旗舰店:风靡亚洲毛孔收敛水
2018/04/26 全球购物
Skip Hop官网:好莱坞宝宝挚爱品牌
2018/06/17 全球购物
Wedgwood英国官方网站:英式精致骨瓷餐具、礼品与生活精品,源于1759年
2019/09/02 全球购物
审核会计岗位职责
2013/11/08 职场文书
党员干部廉洁承诺书
2014/05/28 职场文书
离职告别感言
2015/08/04 职场文书
新手必备之MySQL msi版本下载安装图文详细教程
2021/05/21 MySQL
详解JAVA的控制语句
2021/11/11 Java/Android