Sorry if this is not clear, I’m new to this discourse.
My problem is that whenever I move, I move TOWARDS the enemy. I know which code did it but I’m really bad at moveXY in the desert. So please help.
// Get to the Oasis by moving down 10m at a time.
// Build fences 20m to the left of each ogre.
while(true) {
var enemy = hero.findNearestEnemy();
var x = hero.pos.x;
var y = hero.pos.y;
if (enemy) {
// buildXY a "fence" 20 meters to enemy's left.
x = x + 20;
hero.buildXY("fence", enemy.pos.x,enemy.pos.y);
} else {
// moveXY down 10 meters.
y = y- 10;
hero.moveXY(x, y);
}
}