• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python实现的简单RPG游戏流程实例

python实现的简单RPG游戏流程实例

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了python实例,python程序实例,python脚本实例,python项目实例,python实例教程等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了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 ()

</div>

希望本文所述对大家的Python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • Python只用40行代码编写的计算器实例
  • Python使用PDFMiner解析PDF代码实例
  • Python使用PDFMiner解析PDF代码实例
  • 利用Python获取操作系统信息实例
  • python相似模块用例
  • 实例解析Python设计模式编程之桥接模式的运用
  • Python实现短网址ShortUrl的Hash运算实例讲解
  • Python读取Excel的方法实例分析
  • Python读取Excel的方法实例分析
  • Python实现批量修改文件名实例

相关文章

  • 玩转python爬虫之正则表达式
  • Python完全新手教程
  • 用Python脚本生成Android SALT扰码的方法
  • 使用Python简单的实现树莓派的WEB控制
  • wxpython中利用线程防止假死的实现方法
  • python中执行shell的两种方法总结
  • python正则表达式之作业计算器
  • 使用Python的Scrapy框架编写web爬虫的简单示例
  • Python按行读取文件的实现方法【小文件和大文件读取】
  • python的描述符(descriptor)、装饰器(property)造成的一个无限递归问题分享

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 删除目录下相同文件的python代码(逐级优化)
    • windows下安装Python和pip终极图文教程
    • 使用Python判断质数(素数)的简单方法讲解
    • Python实现把xml或xsl转换为html格式
    • python循环监控远程端口的方法
    • 使用C#配合ArcGIS Engine进行地理信息系统开发
    • Python splitlines使用技巧
    • wxPython 入门教程
    • python连接字符串的方法小结
    • python中List的sort方法指南

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有