# The function maybeBuildTrap defines TWO parameters!
def maybeBuildTrap(x, y):
# Use x and y as the coordinates to move to.
hero.moveXY(x, y)
enemy = hero.findNearestEnemy()
if enemy:
pass
# Use buildXY to build a "fire-trap" at the given x and y.
hero.buildXY("fire-trap", 43, 50)
hero.buildXY("fire-trap", 25, 34)
hero.buildXY("fire-trap", 43, 20)
while True:
# This calls maybeBuildTrap, with the coordinates of the top entrance.
maybeBuildTrap(43, 50)
# Now use maybeBuildTrap at the left entrance!
maybeBuildTrap(25, 34)
# Now use maybeBuildTrap at the bottom entrance!
maybeBuildTrap(34, 20)
My hero just places a fire trap when an ogre comes, but also when a peasant comes
# The function maybeBuildTrap defines TWO parameters!
def maybeBuildTrap(x, y):
# Use x and y as the coordinates to move to.
hero.moveXY(x, y)
enemy = hero.findNearestEnemy()
if enemy:
pass
# Use buildXY to build a "fire-trap" at the given x and y.
hero.buildXY("fire-trap", x, y)
while True:
# This calls maybeBuildTrap, with the coordinates of the top entrance.
maybeBuildTrap(43, 50)
# Now use maybeBuildTrap at the left entrance!
maybeBuildTrap(25, 34)
# Now use maybeBuildTrap at the bottom entrance!
maybeBuildTrap(34, 20)
This is an easy fix.
Look at where your hero goes when he’s supposed to be going to the bottom entrance. Hover your mouse over the coordinates where he is. It will say 34, 20, which is where you told him to go, but it’s not the wooden cross at the bottom entrance. Hover your mouse over the cross and see what is says the coordinates are, then put that into your maybeBuildTrap() function instead of 34, 20.
I realize this may just be a typo, especially considering the numbers are right, they’re just in the wrong order.
Danny
Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic , which shows all essentials of this board! Thanks!