代码展示

class jl:
weight=60
color='red'
hight=180
energy=3
def init(self,x,y):
self.x=x
self.y=y
def run(self,t):
self.energy=self.energy-1
if t=='w':
print("已经向前行走了一步!","目前的坐标为:{},剩余能量为%d".format((self.x+1,self.y))%(self.energy))
self.x=self.x+1
elif t=='s':
print("已经向后行走了一步!","目前的坐标为:{},剩余能量为%d".format((self.x-1,self.y))%(self.energy))
self.x=self.x-1
elif t=='a':
print("已经向左行走了一步!","目前的坐标为:{},剩余能量为%d".format((self.x,self.y+1))%(self.energy))
self.y=self.y+1
elif t=='d':
print("已经向右行走了一步!","目前的坐标为:{},剩余能量为%d".format((self.x,self.y-1))%(self.energy))
self.y=self.y-1
elif t==' ':
print("你已经完成了跳的动作!","坐标没变,但能量减少为%d"%(self.energy))
else:
print("输入错误!")
self.energy=self.energy+1
print("游戏开始!","你准备好了吗?")
print("先说一下说明吧,你如果不想玩了,可以按0键和回车键结束游戏哦!")
print("下面便是游戏的内容了,Let's go!")
print("首先我们需要准备一些初始工作,请输入你想在的初始坐标x和y:")
x=eval(input("X=:"))
y=eval(input("Y=:"))
game=jl(x,y)
while 1:
p=input("请输入动作:")
if p=='0'or game.energy==0:
print("游戏结束!")
break
else:
game.run(p)

要点

好弱智。。。