Commit abde1064 by BellCodeEditor

auto save

parent c6188a1e
Showing with 56 additions and 0 deletions
import turtle #导入turtle
pen=turtle.Pen()#创建画笔
pen1=turtle.Pen()
pen.write("春晓\n春眠不觉晓,\n处处闻啼鸟。\n夜来风雨声,\n花落知多少。",
font=("Times",20,"normal"))
pen1.pensize(10)
pen1.pencolor("red")
pen1.left(45)
pen1.forward(100)
pen1.circle(50,180)
pen1.right(90)
pen1.circle(50,180)
pen1.forward(100)
pen1.hideturtle()
pen.hideturtle()#隐藏画笔
turtle.done()#保存画布
\ No newline at end of file
class Hero:
def __init__(self,name):
self.level=1
self.name=name
self.hp=250
self.attack=50
def combat(self,enemy):
enemy.hp -=self.attack
info1=self.name+'对'+enemy.name+'发起进攻'
info2='造成'+str(self.attack)+'点伤害,'
if enemy.hp > 0:
info3=e
nemy.name+'还剩下'+str(enemy.hp)+'血量'
info=in
fo1+info2+info3
print(i
nfo)
else:
info3=enemy.name+'阵亡,游戏结束'
info=info1+info2+info3
print(info)
exit()
class Player(Hero):
def __init__(self,name):
super().__init__(name)
self.hp=200
self.attack=100
yase=Hero("亚瑟")
houyi=Player("后裔","射手")
houyi.combat(yase)
houyi.combat(yase)
houyi.combat(yase)
\ 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