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 参数列表中的self 显式不等于冗余
Dec 01 Python
python进阶教程之循环对象
Aug 30 Python
Python中的模块和包概念介绍
Apr 13 Python
python spyder中读取txt为图片的方法
Apr 27 Python
Python利用splinter实现浏览器自动化操作方法
May 11 Python
解决Django的request.POST获取不到内容的问题
May 28 Python
Python中的Socket 与 ScoketServer 通信及遇到问题解决方法
Apr 01 Python
Python中py文件转换成exe可执行文件的方法
Jun 14 Python
python实现两个dict合并与计算操作示例
Jul 01 Python
wxPython实现画图板
Aug 27 Python
Python自定义聚合函数merge与transform区别详解
May 26 Python
Python手拉手教你爬取贝壳房源数据的实战教程
May 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
通过文字传递创建的图形按钮
2006/10/09 PHP
PHP设计模式之简单工厂和工厂模式实例分析
2019/03/25 PHP
Jquery增加鼠标中间功能mousewheel的实例代码
2013/09/05 Javascript
多种方法判断Javascript对象是否存在
2013/09/22 Javascript
利用jQuery实现可输入搜索文字的下拉框
2013/10/23 Javascript
Javascript中string转date示例代码
2013/11/01 Javascript
jQuery取得select选择的文本与值的示例
2013/12/09 Javascript
两种方法实现在HTML页面加载完毕后运行某个js
2014/06/16 Javascript
JavaScript里四舍五入函数round用法实例
2015/04/06 Javascript
jQuery实现仿路边灯箱广告图片轮播效果
2015/04/15 Javascript
js中日期的加减法
2015/05/06 Javascript
javascript模拟评分控件实现方法
2015/05/13 Javascript
JQuery日期插件datepicker的使用方法
2016/03/03 Javascript
jQuery实现遍历复选框的方法示例
2017/03/06 Javascript
JS实现按钮控制计时开始和停止功能
2017/07/27 Javascript
vue.js响应式原理解析与实现
2020/06/22 Javascript
使用RN Animated做一个“添加购物车”动画的方法
2018/09/12 Javascript
小程序组件之自定义顶部导航实例
2019/06/12 Javascript
Vue 实现简易多行滚动"弹幕"效果
2020/01/02 Javascript
node.js使用http模块创建服务器和客户端完整示例
2020/02/10 Javascript
Python中endswith()函数的基本使用
2015/04/07 Python
谈谈Python进行验证码识别的一些想法
2016/01/25 Python
浅谈python中的面向对象和类的基本语法
2016/06/13 Python
Windows下Python2与Python3两个版本共存的方法详解
2017/02/12 Python
Python使用python-docx读写word文档
2019/08/26 Python
python图形开发GUI库pyqt5的详细使用方法及各控件的属性与方法
2020/02/14 Python
python实现粒子群算法
2020/10/15 Python
Python常用扩展插件使用教程解析
2020/11/02 Python
html5图片上传预览示例分享
2014/04/14 HTML / CSS
amazeui页面校验功能的实现代码
2020/08/24 HTML / CSS
运动会开幕式解说词
2014/02/05 职场文书
大学新闻系自荐书
2014/05/31 职场文书
责任书范本大全
2015/05/11 职场文书
军训阅兵新闻稿
2015/07/17 职场文书
公司费用报销管理制度
2015/08/04 职场文书
MySQL数据库实验实现简单数据库应用系统设计
2022/06/21 MySQL