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算法应用实战之队列详解
Feb 04 Python
Python+OpenCV人脸检测原理及示例详解
Oct 19 Python
python 实现对文件夹内的文件排序编号
Apr 12 Python
python图的深度优先和广度优先算法实例分析
Oct 26 Python
Python使用qrcode二维码库生成二维码方法详解
Feb 17 Python
python 爬取免费简历模板网站的示例
Sep 27 Python
如何设置PyCharm中的Python代码模版(推荐)
Nov 20 Python
Python urllib request模块发送请求实现过程解析
Dec 10 Python
pycharm 复制代码出现空格的解决方式
Jan 15 Python
Python实现疫情地图可视化
Feb 05 Python
Django项目在pycharm新建的步骤方法
Mar 02 Python
Python基础之操作MySQL数据库
May 06 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的反射类ReflectionClass、ReflectionMethod使用实例
2014/08/05 PHP
PHPUnit安装及使用示例
2014/10/29 PHP
php链式操作的实现方式分析
2019/08/12 PHP
再谈IE中Flash控件的自动激活 ObjectWrap
2007/03/09 Javascript
js中关于String对象的replace使用详解
2011/05/24 Javascript
关于javascript中的typeof和instanceof介绍
2012/12/04 Javascript
JavaScript中return false的用法
2015/03/12 Javascript
微信小程序 绘图之饼图实现
2016/10/24 Javascript
微信小程序支付及退款流程详解
2017/11/30 Javascript
在react-router4中进行代码拆分的方法(基于webpack)
2018/03/08 Javascript
JavaScript如何对图片进行黑白化
2018/04/10 Javascript
vue中使用gojs/jointjs的示例代码
2018/08/24 Javascript
Puppet的一些技巧
2018/09/17 Javascript
基于vue.js组件实现分页效果
2018/12/29 Javascript
JavaScript跳出循环的三种方法(break, return, continue)
2019/07/30 Javascript
JS通过识别id、value值对checkbox设置选中状态
2020/02/19 Javascript
[44:50]2018DOTA2亚洲邀请赛 4.1 小组赛 A组 TNC vs VG
2018/04/02 DOTA
Python UnicodeEncodeError: 'gbk' codec can't encode character 解决方法
2015/04/24 Python
浅析Python中的多重继承
2015/04/28 Python
python在TXT文件中按照某一字符串取出该字符串所在的行方法
2018/12/10 Python
python对象与json相互转换的方法
2019/05/07 Python
Python如何实现转换URL详解
2019/07/02 Python
wxPython色环电阻计算器
2019/11/18 Python
在Mac中PyCharm配置python Anaconda环境过程图解
2020/03/11 Python
如何在Python 游戏中模拟引力
2020/03/27 Python
用Python进行websocket接口测试
2020/10/16 Python
Python根据字符串调用函数过程解析
2020/11/05 Python
HTML5自定义data-* data(obj)属性和jquery的data()方法的使用
2012/12/13 HTML / CSS
销售顾问的岗位职责
2013/11/13 职场文书
青年文明号复核材料
2014/02/11 职场文书
读书活动实施方案
2014/03/10 职场文书
民事诉讼授权委托书范文
2014/08/02 职场文书
乡镇科协工作总结2015
2015/05/19 职场文书
少先队中队工作总结2015
2015/07/23 职场文书
mysql优化
2021/04/06 MySQL
springboot利用redis、Redisson处理并发问题的操作
2021/06/18 Java/Android