I am trying collect all the horses put in the fence. however I always got one reminder, it ran out of time.
How would you successful for this level?
one more thing I dont understand why when they say “hi” and move back to “geez” by added 7 and move back to “hi” back forth over till they see the horse.
What I am trying to do is say “hi” several of time by subtract -7 number till the Conditional Statements become false. If I want to set up Conditional Statements for (x2 <= 79) (this.say(“geez”)) it refused let my hero walk to all the way to right side at appox 77 number then the Conditional Statements will become false back to (x1 >= 1)?
loop {
// How do you find the nearest friendly unit?
// horse = ?
var horse = this.findNearest(this.findFriends());
if (horse) {
var x1 = this.pos.x - 7;
var x2 = this.pos.x + 7;
var y = this.pos.y;
// var y1 = this.pos.y - 1;
if (x1 >= 7) {
// Move to the horse's y position but use x1 for the x position.
this.moveXY(x1, y);
// x1 += 7;
// this.moveXY(x1, y);
this.say('hi');
}
else if (x2 <= 79) {
// Move to the horse's y position but use x2 for the x position.
this.moveXY(x2, y);
// x2 -= 7;
// this.moveXY(x2, y);
this.say('geez');
}
var distance = this.distanceTo(horse);
if (distance <= 15) {
this.say("Whoa");
// Move to the red x to return the horse to the farm.
this.moveXY(27, 54);
this.say("stay!");
// Move back out into the pasture to begin looking for the next horse.
this.moveXY(28, 18);
}
}
}