Oasis Level Help


#1

Help!!! I’m stuck!!! I used this code but my hero keeps dying. He goes to the right but then moves to the left only to be killed by the yaks. Help please!!! Ur hep shall be very much appreciated.

// Move forward to reach the oasis,
// but move back to avoid nearby yaks.

loop {
enemy = this.findNearest(this.findEnemies());
if (enemy && this.distanceTo(enemy) < 20) {
// Move to the left by subtracting 10 from your X coordinate.
x = this.pos.x - 4;
} else {
// Move to the right by addding 10 from your X coordinate.
x = this.pos.x + 4;
}
this.moveXY(x, this.pos.y);
}


#2

Please format your code according to the FAQ.

You didn’t follow the directions. Do that, then come back.


#3

Sorry. Already did it anyways.