Hello, I have written this code for this level and I really do not understand what is wrong, at the end of the process and when entering the “else” instead of going down 10 meters, the hero goes up 10 meters, I have tried to go negative and continue same, what’s wrong? could someone give me a hand? please thanks!
All you have to do is build a fence at (enemy.pos.x - 20, enemy.pos.y)
. Then, if there is no enemy, you need to move to (hero.pos.x, hero.pos.y - 10)
.
I already did it and it doesn’t work
i think you are forgetting to find a new enemy so your hero will place the fence where the old enemy is and not the new one
What happens when you try it out?
I do not understand the problem, what happens is the following: my hero builds a fence in the 3 corners where enemies appear and in the end the hero should go 10 steps down to complete the level and he does not, instead of going down, goes up, try + and - and it doesn’t work…
also i was checking and the first enemies that appear can easily get out of the fence, this means that a bug was generated since at the end everything is fine but the first enemies come down to attack me and that’s why the hero goes up or so I think
All you have to do is reset the level, then build a fence at 20 meters from the enemy’s position; hero.buildXY("fence", enemy.pos.x - 20, enemy.pos.y)
. Then in your else statement move ten meters below your current hero’s position; hero.moveXY(hero.pos.x, hero.pos.y-10)
.
I’ll do it from 0 again, I’ll let you know in a while how I’m doing with the result thanks for your comments, I’ll be back in a while.