Commit dd1b0974 by BellCodeEditor

save project

parent c7e94689
Showing with 21 additions and 35 deletions
class Hero: # 英雄类 import turtle
def __init__(self, name): # 实例属性 len=20
self.name = name screen=turtle.Screen()
self.level = 1 screen.bgcolor("light green")
self.hp = 250 pen=turtle.Pen()
self.attack = 40 pen.penup()
self.max_hp = self.hp pen.goto(100,-100)
pen.write("傻逼,\n大傻逼",font=("time",20,"normal"))
pen.hideturtle()
def combat(self, enemy): # 攻击功能 pen1=turtle.Pen()
info1 = self.name+"对"+enemy.name+"发起进攻," pen1.pensize(5)
info2 = "造成"+str(self.attack)+"点伤害," pen1.pencolor("green")
enemy.hp -= self.attack pen1.left(45)
if enemy.hp > 0: pen1.forward(2*len)
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量" pen1.circle(len,180)
info = info1+info2+info3 pen1.right(90)
print(info) pen1.circle(len,180)
else: pen1.forward(2*len)
info3 = enemy.name+"阵亡,游戏结束" pen1.hideturtle()
info = info1+info2+info3 turtle.done()
print(info) \ No newline at end of file
exit()
class Player(Hero): # 玩家英雄
def __init__(self,name,Hero_type):
super().__init__(name)
self.hp=200
self.attack=50
self.Hero_type=Hero_type
print("角色"+str(self.name)+"创建成功,"+"英雄类型为"+str(Hero_type))
print("当前等级,血量,攻击力分别为:"+str(self.level)+str(self.hp)+str(self.attack))
a=Player()
print(a)
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