Problem with "Oasis" Level Javascript


#1

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);
    }
}

#2

Your code works fine on my computer, it must be a problem with your equipment, could you send a screenshot, or if not, a list of the names of your equipment.
Thanks :lion:


#3

So I switched out the character to someone who was slower and it worked. Thanks! It was driving me crazy because I didn’t think there was anything wrong with the code.
Thank you for helping me solve this one.


#4

That’s alright.
:lion: