Commit 11c817db by BellCodeEditor

auto save

parent 1908b6f2
Showing with 70 additions and 7 deletions
from turtle import *
def Draw_circle(color,size,x,y):
pencolor(color) #画笔颜色
pensize(8) #画笔粗细
pu() #抬笔
goto(x,y)
pd() #落笔
circle(size) #size表示圆环半径
#黑色
Draw_circle('black',100,50,0)
#蓝色
Draw_circle('blue',100,-170,0)
#红色
Draw_circle('red',100,270,0)
#绿色
Draw_circle('green',100,160,-120)
#黄色
Draw_circle('yellow',100,-60,-120)
hideturtle() #隐藏画笔
done()
\ No newline at end of file
import random #导入随机模块
class Hero(object):
def __init__(self, name):
self.name = name
......@@ -7,7 +8,9 @@ class Hero(object):
self.max_hp = self.hp
def cure(self): # 治疗
???
self.hp = self.hp + 60
if self.hp > self.max_hp:
self.hp = self.max_hp
print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击
......@@ -33,10 +36,34 @@ class Player(Hero):
self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
def cure(self):
blood = random.randint(30,50)
self.hp += blood #加血
if self.hp > self.max_hp:
self.hp = self.max_hp
print(self.name + "使用了治疗术,血量增加",blood,"目前血量为",self.hp)
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
houyi.combat(yase)
yase.combat(houyi)
houyi.cure()
yase.cure()
\ No newline at end of file
print('-' * 30)
print(' 战斗开始')
while True:
print('-' * 30)
#玩家攻击
choice = input("请选择释放的英雄技能:(1攻击 2治疗)q退出")
if choice == 'q':
print('游戏结束')
break
elif choice == '1':
houyi.combat(yase) #后羿攻击亚瑟
elif choice == '2':
houyi.cure() #使用治疗术
else:
print('请重新输入1或2或q')
continue
#敌方攻击
status = random.randint(1,3)
if status == 1:
yase.combat(houyi) #yase攻击
else:
yase.cure() #敌人使用治疗术
#import turtle #导入模块
from turtle import * #导入
def Draw_star(length): #length表示五角星边长
fillcolor('red') #填充颜色设为红色
begin_fill() #开始填充
for i in range(5):
fd(length)
rt(144)
end_fill() #结束填充
Draw_star(200) #调用
bk(300)
Draw_star(300)
done()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment