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简单的函数定义和用法实例
May 07 Python
Python编程中实现迭代器的一些技巧小结
Jun 21 Python
详解利用OpenCV提取图像中的矩形区域(PPT屏幕等)
Jul 01 Python
python 自动轨迹绘制的实例代码
Jul 05 Python
Python如何调用JS文件中的函数
Aug 16 Python
详解Python可视化神器Yellowbrick使用
Nov 11 Python
wxPython色环电阻计算器
Nov 18 Python
Python3标准库glob文件名模式匹配的问题
Mar 13 Python
Python基于smtplib协议实现发送邮件
Jun 03 Python
keras 解决加载lstm+crf模型出错的问题
Jun 10 Python
Django多数据库联用实现方法解析
Nov 12 Python
python 多线程爬取壁纸网站的示例
Feb 20 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通过strpos查找字符串出现位置的方法
2015/03/17 PHP
PHP自定义函数获取URL中一级域名的方法
2016/08/23 PHP
如何通过View::first使用Laravel Blade的动态模板详解
2017/09/21 PHP
smarty模板的使用方法实例分析
2019/09/18 PHP
设为首页加入收藏兼容360/火狐/谷歌/IE等主流浏览器的代码
2013/03/26 Javascript
Javascript中常见的校验如域名、手机、邮箱等等
2014/01/02 Javascript
JavaScript中奇葩的假值示例应用
2014/03/11 Javascript
javascript轻量级库createjs使用Easel实现拖拽效果
2016/02/19 Javascript
详解Javascript中的Object对象
2016/02/28 Javascript
用NodeJS实现批量查询地理位置的经纬度接口
2016/08/16 NodeJs
解决URL地址中的中文乱码问题的办法
2017/02/10 Javascript
jquery实现tab键进行选择后enter键触发click行为
2017/03/29 jQuery
node.js之基础加密算法模块crypto详解
2018/09/11 Javascript
jQuery实现简易QQ聊天框
2020/02/10 jQuery
Nuxt配置Element-UI按需引入的操作方法
2020/07/06 Javascript
JavaScript 实现拖拽效果组件功能(兼容移动端)
2020/11/11 Javascript
JavaScript async/await原理及实例解析
2020/12/02 Javascript
[01:00]一分钟回顾2018DOTA2亚洲邀请赛现场活动
2018/04/07 DOTA
Python编程语言的35个与众不同之处(语言特征和使用技巧)
2014/07/07 Python
Python标准库06之子进程 (subprocess包) 详解
2016/12/07 Python
Python中查看文件名和文件路径
2017/03/31 Python
python email smtplib模块发送邮件代码实例
2018/04/26 Python
Python实现快速傅里叶变换的方法(FFT)
2018/07/21 Python
python使用多进程的实例详解
2018/09/19 Python
Python3将ipa包中的文件按大小排序
2020/04/17 Python
python 获取计算机的网卡信息
2021/02/18 Python
html+js 实现markdown编辑器效果
2019/10/23 HTML / CSS
携程旅行网:中国领先的在线旅行服务公司
2017/02/17 全球购物
护理毕业生自我鉴定
2014/02/11 职场文书
2014年预备党员学习新党章思想汇报
2014/09/15 职场文书
小浪底导游词
2015/02/12 职场文书
学校禁毒宣传活动总结
2015/05/08 职场文书
解析Redis Cluster原理
2021/06/21 Redis
SSM项目使用拦截器实现登录验证功能
2022/01/22 Java/Android
Python中的 enumerate和zip详情
2022/05/30 Python
基于Python编写一个监控CPU的应用系统
2022/06/25 Python