I can’t pass but I finished the goal.Help me !
code:
Use fire-traps to defeat the ogres attacking the trading post.
loop:
enemy = self.findNearestEnemy()
if enemy:
if enemy.pos.x < self.pos.x:
# If the enemy is to the left, build a fire-trap to the left.
hero.shield()
hero.buildXY("fence", 40-19, 34)
hero.buildXY("fence", 40-19, 34+2)
hero.buildXY("fence", 40-19, 34-2)
pass
elif enemy.pos.x > self.pos.x:
# If the enemy is to the right, build a fire-trap to the right.
hero.buildXY("fence", 40+19, 34)
hero.buildXY("fence", 40+19, 34+2)
hero.buildXY("fence", 40+19, 34-2)
pass
elif enemy.pos.y < self.pos.y:
# If the enemy is below the hero, build a fire-trap below.
hero.buildXY("fence", 40, 34-19)
hero.buildXY("fence", 40+2, 34-19)
hero.buildXY("fence", 40-2, 34-19)
pass
elif enemy.pos.y > self.pos.y:
# If the enemy is above the hero, build a fire-trap above.
hero.buildXY("fence", 40, 53)
hero.buildXY("fence", 40-2, 53)
hero.buildXY("fence", 40+2, 53)
pass
self.moveXY(40, 34)