// Twoim zadaniem jest powiedzieć im jaka jest odległość do ogrów.

// Ta funkcja znajduje najbliższego przeciwnika i zwraca odległość do niego.
function nearestEnemyDistance() {
    var enemy = hero.findNearestEnemy();
    // Jeśli nie ma wrogów, funkcja zwraca 0
    var result = 0;
    if (enemy) {
        result = hero.distanceTo(enemy);
    }


    return result;
}

while (true) {
    // Wywołaj nearestEnemyDistance() i
    // save the result in the variable enemyDistance.
    var enemyDistance = nearestEnemyDistance();
    // If the enemyDistance is greater than 0:
    if (enemyDistance > 0) {
        
    
        // Say the value of enemyDistance variable.
    hero.say(enemyDistance);
    }
}

 

 

 

 

 

 

 

 

Projektuję strony www Lublin na Joomla i WordPress