loop {     enemy = this.findNearestEnemy();        distance = this.distanceTo(enemy);     // Add logic to only move when a yak is less than 10 meters away.     x = this.pos.x + 10;     y = this.pos.y; if(this.distanceTo(enemy) < 10)      // Move right by adding to your current X coordinate.          this.moveXY( x, y); }