here is my code while True:
enemy = hero.findNearestEnemy()
if enemy:
if enemy.pos.x < hero.pos.x:
# If the enemy is to the left, build a fire-trap to the left.
hero.buildXY(“fire-trap”, enemy.pos.x, hero.pos.x) + 10
pass
elif enemy.pos.x > hero.pos.x:
# If the enemy is to the right, build a fire-trap to the right.
hero.buildXY(“fire-trap”, enemy.pos.x, hero.pos.x) + 10
pass
elif enemy.pos.y < hero.pos.y:
# If the enemy is below the hero, build a fire-trap below.
hero.buildXY(“fire-trap”, enemy.pos.x, hero.pos.x) + 10
pass
elif enemy.pos.y > hero.pos.y:
# If the enemy is above the hero, build a fire-trap above.
hero.buildXY(“fire-trap”, enemy.pos.x, hero.pos.x) + 10
pass
hero.moveXY(enemy.pos.x, enemy.pos.y)
`
HELP HElP HELP
Can you format your code as it is described here?
Andrei
ok I will
while True:
enemy = hero.findNearestEnemy()
if enemy:
if enemy.pos.x < hero.pos.x:
# If the enemy is to the left, build a fire-trap to the left.
hero.buildXY("fire-trap", enemy.pos.x, hero.pos.x) + 10
pass
elif enemy.pos.x > hero.pos.x:
# If the enemy is to the right, build a fire-trap to the right.
hero.buildXY("fire-trap", enemy.pos.x, hero.pos.x) + 10
pass
elif enemy.pos.y < hero.pos.y:
# If the enemy is below the hero, build a fire-trap below.
hero.buildXY("fire-trap", enemy.pos.x, hero.pos.x) + 10
pass
elif enemy.pos.y > hero.pos.y:
# If the enemy is above the hero, build a fire-trap above.
hero.buildXY("fire-trap", enemy.pos.x, hero.pos.x) + 10
pass
hero.moveXY(enemy.pos.x, enemy.pos.y)
can you help can you help
Instead of all of those, try to introduce the coordonates of the mark that you want to build on each time and build the fire trap there.
Andrei
I don’t know what you mean
Well do you see the red marks?
Andrei
ya so what do you do with them cause every time I place a fire-trap on it the hero.just stands there
Then, if you want to build it left, then use the coordonates of the left mark, if tou want to build it to the right use the coordonates of the right mark and like this for all of the directions. After that you should return to the center.
Andrei
I don’t return I keep on build in fire traps
Can you show me your recent code?
Andrei
ok I will just wait **WAIT WAIT
**
while True:
enemy = hero.findNearestEnemy()
if enemy:
if enemy.pos.x < hero.pos.x:
# If the enemy is to the left, build a fire-trap to the left.
hero.buildXY("fire-trap", 25, 34)
hero.moveXY(40, 33)
elif enemy.pos.x > hero.pos.x:
# If the enemy is to the right, build a fire-trap to the right.
hero.buildXY("fire-trap", 55, 34)
hero.moveXY(40, 33)
elif enemy.pos.y < hero.pos.y:
# If the enemy is below the hero, build a fire-trap below.
hero.buildXY("fire-trap", 40, 19)
hero.moveXY(40, 33)
elif enemy.pos.y > hero.pos.y:
# If the enemy is above the hero, build a fire-trap above.
hero.buildXY("fire-trap", 40, 48)
hero.moveXY(40, 33)
``` :ice_hockey: :joystick: :tennis: :bowling: :3rd_place_medal: :2nd_place_medal: :cricket_bat_and_ball: :cricket_bat_and_ball: :cricket_bat_and_ball: :cricket_bat_and_ball: :tennis: :1st_place_medal: :2nd_place_medal:
Try to only put pne of these after you check and bulld the fire trap (put only one of them but one that in not outside the ifs that build the fire traps and it is in the if enemy).
Andrei