Commit 7078929d by BellCodeEditor

auto save

parent 96a817a6
Showing with 8 additions and 26 deletions
# 英雄角色类 # 利用write()帮助悟空给诺依回信吧~
class Hero(object): import turtle # 导入turtle模块
def __init__(self, name): screen=turtle.Screen() # 创建画布
self.level = 1 screen.bgcolor("light blue") # 设置画布的颜色
self.hp = 350 pen=turtle.Pen() # 创建一支画笔,用来写字
self.attack = 30 pen.write("君不见,\n黄河之水天上来,\n奔流到海不复回。\n",font=("Times",20,"normal"))
self.name = name pen.hideturtle() # 隐藏画笔
def combat(self,enemy): # 攻击 turtle.done() # 保存画布
enemy.hp -= self.attack
info1 = self.name + '对' + enemy.name + '发起攻击,'
info2 = '造成' + str(self.attack) + '真实伤害,'
if enemy.hp < 0:
info3 = enemy.name + '阵亡'
else:
info3 = enemy.name + '还剩下' + str(enemy.hp) + '点生命值'
print(info1 + info2 + info3)
class B(Hero):
super.__init__(name)
self
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
def
\ 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