Hello,
I’ve been stuck on this level for awhile now. My hero moves right to avoid the Yaks but runs into one when moving left.
while(true) {
var x = hero.pos.x;
var y = hero.pos.y;
var enemy = hero.findNearestEnemy();
if (enemy && hero.distanceTo(enemy) < 10) {
// Subtract 10 from x to move left.
x -= 10;
// Use moveXY to move to the new x, y position.
hero.moveXY(x,y);
} else {
// Add 10 to x to move right.
x += 10;
// Use moveXY to move to the new x, y position.
hero.moveXY(x,y);
}
}