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 18 Python
python检测某个变量是否有定义的方法
May 20 Python
Python3实现将文件树中所有文件和子目录归档到tar压缩文件的方法
May 22 Python
Python爬虫模拟登录带验证码网站
Jan 22 Python
python实现机器人行走效果
Jan 29 Python
详解多线程Django程序耗尽数据库连接的问题
Oct 08 Python
python将控制台输出保存至文件的方法
Jan 07 Python
python类中super() 的使用解析
Dec 19 Python
Python中私有属性的定义方式
Mar 05 Python
python3的pip路径在哪
Jun 23 Python
matplotlib bar()实现多组数据并列柱状图通用简便创建方法
Feb 24 Python
python实现简单倒计时功能
Apr 21 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 数组遍历方法大全(foreach,list,each)
2010/06/30 PHP
php 生成唯一id的几种解决方法
2013/03/08 PHP
php 批量添加多行文本框textarea一行一个
2014/06/03 PHP
PHP中使用Imagick读取pdf并生成png缩略图实例
2015/01/21 PHP
PHP使用PDO操作数据库的乱码问题解决方法
2016/04/08 PHP
总结PHP中数值计算的注意事项
2016/08/14 PHP
CI框架中类的自动加载问题分析
2016/11/21 PHP
PHP中的函数声明与使用详解
2017/05/27 PHP
漂亮的widgets,支持换肤和后期开发新皮肤(2007-4-27已更新1.7alpha)
2007/04/27 Javascript
两个比较有用的Javascript工具函数代码
2010/02/17 Javascript
基于jquery创建的一个图片、视频缓冲的效果样式插件
2012/08/28 Javascript
jQuery制作仿腾讯web qq用户体验桌面
2013/08/20 Javascript
js获取某元素的class里面的css属性值代码
2014/01/16 Javascript
Node.js读写文件之批量替换图片的实现方法
2016/09/07 Javascript
JS实现动画兼容性的transition和transform实例分析
2016/12/13 Javascript
概述一个页面从输入URL到页面加载完的过程
2016/12/16 Javascript
vue-cli脚手架config目录下index.js配置文件的方法
2018/03/13 Javascript
Vue 用Vant实现时间选择器的示例代码
2019/10/25 Javascript
JS运算符优先级与表达式示例详解
2020/09/04 Javascript
Python编写的com组件发生R6034错误的原因与解决办法
2013/04/01 Python
python数据处理实战(必看篇)
2017/06/11 Python
用Eclipse写python程序
2018/02/10 Python
3个用于数据科学的顶级Python库
2018/09/29 Python
对python调用RPC接口的实例详解
2019/01/03 Python
浅析python内置模块collections
2019/11/15 Python
python绘制动态曲线教程
2020/02/24 Python
美国温暖商店:The Warming Store
2018/12/15 全球购物
adidas菲律宾官网:adidas PH
2020/02/07 全球购物
国贸专业大学生职业生涯规划范文
2014/01/10 职场文书
质检部经理岗位职责
2014/02/19 职场文书
低碳日宣传活动总结
2014/07/09 职场文书
婚前协议书范本
2014/10/27 职场文书
2014年高一班主任工作总结
2014/12/05 职场文书
2015年学校远程教育工作总结
2015/07/20 职场文书
国产动画《万圣街》日语配音版制作决定!
2022/03/20 国漫
keepalived + nginx 实现高可用方案
2022/12/24 Servers