11、跃火林中
# 在这关,别碰恶魔石!往其他方向移动避开它们!
while True:
evilstone = hero.findNearestItem()
if evilstone:
pos = evilstone.pos
if pos.x == 46:
# 如果恶魔石在右边,走到左边。
hero.moveXY(34, 22)
pass
else:
# 如果恶魔石在左边,走到左边。
hero.moveXY(46, 22)
pass
else:
# If there's no evilstone, go to the middle.
hero.moveXY(40, 22)
pass
这关的提示有一个地方错误了
12、村庄漫游者
这关有开始定义函数
# This defines a function called findAndAttackEnemy
def findAndAttackEnemy():
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
# This code is not part of the function.
while True:
# Now you can patrol the village using findAndAttackEnemy
hero.moveXY(35, 34)
findAndAttackEnemy()