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程序设计有所帮助。


猜你喜欢
- 前言当我们需要安装python的第三方库时,通常都是打开cmd输入pip install xxx去安装。但是默认安装路径在C盘,极大占用空间
- 本文实例讲述了PHP抓取及分析网页的方法。分享给大家供大家参考,具体如下:抓取和分析一个文件是非常简单的事。这个教程将通过一个例子带领你一步
- 一、模拟登录图书馆管理系统我们可以先看一下登录页面(很多学校这些管理系统页面就是很low):两种方式去模拟登录图书馆:1. 构造登录表单进行
- 在 Django 网站中使用 mailgun 的邮件收发服务。1.在 mailgun 官网上注册个账号(免费,免费账号每个月有10000条收
- 整数对象在Python内部用PyIntObject结构体表示:typedef struct {PyObject_HEADlong ob_iv
- 一张损坏的表的症状通常是查询意外中断并且你能看到例如这些错误:◆ “tbl_name.frm”被锁定不能改变。◆ 不能找到文件“tbl_na
- 标记路径演示效果:实例代码import matplotlib.pyplot as pltimport matplotlib.path as
- 本文实例讲述了PHP实现断点续传乱序合并文件的方法。分享给大家供大家参考,具体如下:分割成多个文件发送,由于网络原因并不上先发就能发接收到。
- 1.原始数据是这样的2.脚本如下:import pandas as pddf = pd.read_excel(r'E:\untitl
- 前言相信各位一定有收到过这样的群发短信,据说还被归类为玩转微信的五大技巧之一╮(╯▽╰)╭但,其实,只要跑一下脚本,就轻松找出删除自己的好友
- 核心代码由于HttpServletRequest不能直接取出文件数据,所以将其强制转换为MultipartHttpServletReques
- 本篇文章通过调用opencv里的函数简单的实现了对图像里特定颜色提取与定位,以此为基础,我们可以实现对特定颜色物体的前景分割与定位,或者特定
- 用numpy做矩阵运算时,少不了用到矩阵乘法。本文帮你迅速区分multiply, matmul和dot的区别。numpy官方文档中的说明:(
- 一、标准的数据集流程梳理分为几个步骤数据准备以及加载数据库–>数据加载器的调用或者设计–>
- 没有Promise的并发请求在Web开发中,我们经常需要发起多个异步请求来获取数据。例如,我们可能需要从服务器获取一些用户信息、文章内容、评
- PIL(Python Image Library)是python的第三方图像处理库,但是由于其强大的功能与众多的使用人数,几乎已
- np.arange 步长0.1问题两个小测试:1)count输出什么?import numpy as np y_m
- ul设置浮动后不能自适应高度,也就是不能撑开父容器,不能自适应内容的高度。解决方法是在ul结束标签前加个清除浮动。 &
- 前言:经过一段时间的测试验证,决定使用RPM来做Golang服务的部署方式. 我们组关于代码的部署方式主要有这么几种,Python直接使用v
- 前言一道题目是实现一个反转字符串的函数,具体如下:编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组 char[] 的形式给