# Llegar al oasis. Cuidado con los nuevos enemigos: ogros exploradores!
# Subir y hacia la derecha añadiendo a la posición X e Y actual.
Enemigo = hero.findNearestEnemy()
while True:
# Si hay un enemigo, ataca.
if Enemigo:
hero.attack(Enemigo)
# De lo contrario, sigue moviéndote hacia arriba y hacia la derecha.
else:
X = hero.pos.x + 1
Y = hero.pos.y + 1
hero.moveXY(X, Y)
i reach the Oasis, but my hero, never attack the ogres scout, and they reach with me the oasis xD
That don’t make any difference, because is just a variable name, besides, in the previous levels I have not had problems using practically the same parts of code
Eso no hace diferencia alguna, debido a que es solo el nombre de una variable. Ademas, en los niveles anteriores no he tenido problemas usando prácticamente las mismas partes de código!
With your variable outside the while True loop, it is a global variable. Global variables are generally not a good idea and should be avoided. Move your variable definition inside the while True loop and before the if enemy conditional statement.
for me is some strange, because on all levels i play before, ever i put that goblal variables, i just in that level, make that.
well i put the variable, inside the “while True:” and now it’s working
# https://codecombat.com/play/level/sarven-road?
# Llegar al oasis. Cuidado con los nuevos enemigos: ogros exploradores!
# Subir y hacia la derecha añadiendo a la posición X e Y actual.
while True:
# Si hay un enemigo, ataca.
enemigo = hero.findNearestEnemy()
if enemigo:
hero.attack(enemigo)
# De lo contrario, sigue moviéndote hacia arriba y hacia la derecha.
else:
X = hero.pos.x + 1
Y = hero.pos.y + 1
hero.moveXY(X, Y)