python实现的简单RPG游戏流程实例
作者:不吃皮蛋 发布时间:2021-11-13 21:29:53
标签:python,游戏
本文实例讲述了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程序设计有所帮助。
0
投稿
猜你喜欢
- 一、需求描述1.图片展示从如图所示的数据中提取含有"python"、"ubuntu"关键词的所有行数
- 本文实例为大家分享了利用opencv实现SIFT特征提取与匹配的具体代码,供大家参考,具体内容如下1、SIFT1.1、sift的定义SIFT
- 为什么要修改镜像源?一般使用python安装库,会用到pip install xxx 指令或者conda install xxx指令,因为p
- 相比大家都听过自动化生产线、自动化办公等词汇,在没有人工干预的情况下,机器可以自己完成各项任务,这大大提升了工作效率。编程世界里有各种各样的
- Function Comma(str)If Not(IsNumeric(str)) Or 
- import osimport codecsfilenames=os.listdir(os.getcwd())out=file("
- eval 跟json.loads 是不一样的函数,是有实现不一样功能的地方,但是在某些地方它们两个函数的功能是一样的,在这个时候如果对执行效
- 在之前的一篇文章 Python利用 AIML 和 Tornado 搭建聊天机器人微信订阅号 中用 aiml 实现了一个简单的英文聊天机器人订
- 数据准备moduls.py# 构建表结构from django.db import models# 表app01_publishclass
- 本文实例为大家分享了python机器学习实现决策树的具体代码,供大家参考,具体内容如下# -*- coding: utf-8 -*-&quo
- 代码如下:function checkip(checkstring)'用正则判断IP是否合法 dim re1 set re1=new
- 大家好,我们的数据库已经介绍完了,这里给大家总结一下。我们这段主要是学习了SQL的增删改查语句,其中查询是我们的重点。我们是以SQL Ser
- 开发时,通常打开Debug模式会快速定位开发时的一些问题。项目开始部署时,关闭Debug模式,url.py路由静态文件和图片写法:# url
- 数据结构树简介一、树简介树(Tree)是一种抽象的数据结构,是一个数据的集合,集合中的数据组成了一个树状结构。例如上图,看起来像一棵倒挂的树
- 原文件:7.8094,1.0804,5.7632,0.012269,0.008994,-0.003469,-0.79279,-0.06468
- 其实网上已经有许多python语言书写的串口,但大部分都是python2写的,没有找到一个合适的python编写的串口助手,只能自己来写一个
- 也就在前几天,南太平洋岛国汤加发生火山喷发,有专门的专家学者分析,这可能是30年来全球规模最大的一次海底火山喷发,它引发的海啸以及火山灰将对
- 学习使用存储过程(Stored Procedure),是ASP程序员的必须课之一。所有的大型数据库都支持存储过程,比如Oracle
- 目录简介图形加载和说明图形的灰度灰度图像的压缩原始图像的压缩总结简介本文将会以图表的形式为大家讲解怎么在NumPy中进行多维数据的线性代数运
- 在应用中,有时候会 依赖第三方模块执行方法,比如调用某模块的上传下载,数据库查询等操作的时候,如果出现网络问题或其他问题,可能有超时重新请求