python实现的简单RPG游戏流程实例
作者:不吃皮蛋 时间:2021-11-13 21:29:53
本文实例讲述了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,游戏
0
投稿
猜你喜欢
深入理解ASP中FSO的神奇功能
2007-09-18 12:22:00
使用Python给头像戴上圣诞帽的图像操作过程解析
2023-03-17 13:22:01
Django集成MongoDB实现过程解析
2022-07-10 03:32:35
OpenCV+python实现膨胀和腐蚀的示例
2021-06-12 10:35:00
Python命令行参数argv和argparse该如何使用
2022-04-05 01:38:52
MySQL应用技巧之存取权限
2010-08-08 09:10:00
jupyter notebook 添加kernel permission denied的操作
2021-07-06 19:49:14
Python上下文管理器详细使用教程
2021-06-24 05:47:35
TensorFlow2.0矩阵与向量的加减乘实例
2023-12-30 13:21:00
node命令行服务器(http-server)和跨域的实现
2021-03-10 05:00:09
Python如何利用opencv实现手势识别
2023-09-02 21:55:13
Python中条件判断语句的简单使用方法
2022-10-12 00:34:34
python中正则表达式与模式匹配
2023-08-25 22:54:59
设计能力决定权力
2009-06-16 14:48:00
防止网站被采集的理论分析以及十条方法对策第1/2页
2011-03-29 10:38:00
python3环境搭建过程(利用Anaconda+pycharm)完整版
2022-01-16 06:04:47
Oracle针对数据库某一行进行操作的时候,如何将这一行加行锁
2009-03-06 10:37:00
python 爬取百度文库并下载(免费文章限定)
2022-05-08 16:18:28
Python图片验证码降噪和8邻域降噪
2023-09-16 10:05:49
pytorch 利用lstm做mnist手写数字识别分类的实例
2023-01-31 03:15:38