Commit dc01f94e by BellCodeEditor

save project

parent 36617377
Showing with 16 additions and 36 deletions
class Hero: # 英雄类 import turtle
def __init__(self, name): # 实例属性 e=turtle.Screen()
self.name = name pen=turtle.Pen()
self.level = 1 a=50
self.hp = 250 e.bgcolor("pink")
self.attack = 40 pen.pensize(5)
self.max_hp = self.hp pen.pencolor("red")
pen.lt(45)
pen.fd(2*a)
def combat(self, enemy): # 攻击功能 pen.circle(a,180)
info1 = self.name+"对"+enemy.name+"发起进攻," pen.rt(90)
info2 = "造成"+str(self.attack)+"点伤害," pen.circle(a,180)
enemy.hp -= self.attack pen.fd(2*a)
if enemy.hp > 0: pen.hideturtle()
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量" turtle.down()
info = info1+info2+info3 \ No newline at end of file
print(info)
else:
info3 = enemy.name+"阵亡,游戏结束"
info = info1+info2+info3
print(info)
exit()
class Player(Hero): # 玩家英雄
def __init__(self,name):
super().__init__(name)
self.hp = 5
self.attack = 100
self.max_hp = self.hp
print("英雄:"+self.name+".创建成功,"+"\n英雄类型:"+self.herotype+"\n攻击力:"+str(self.attack))
yase = Hero("亚瑟",)
houyi = Man("后羿","射手")
print("玩家的血量值为:",player.hp)
print("玩家的攻击力为:",player.attack)
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