Maybe I am just impatient. I try to survive in the cave my first time. So in the moment I have this:
i = 0
hero.shield()
while i < 4:
----enemy = hero.findNearestEnemy()
----hero.attack(enemy)
----i +1
hero.moveXY(51,41)
my problem is:
after I kill the first wave my stupid hero (or is it me who is stupid? ;)) have no wish to go to 51,41 and I have no clue why. Anybody have an idea?
i = 0
hero.shield()
while i < 4:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
i +1 # you do "+=" instead, add AND ASSIGN
hero.moveXY(51,41) # This line never happens, change the code above
#then it will happen
instead, do a for-loop, the code below is all u need
hero.shield()
for i in range(4):
hero.attack(hero.findNearestEnemy())
hero.moveXY(51,41)
ok, before i started to learn more about while I was learning if and else and there u can say x +1. that was the idea behind. But for this problem I will do like u said, thanks
while True:
enemies = hero.findEnemies()
Index = 0
while Index < len(enemies):
enemy = enemies[Index]
while enemy.health > 0:
hero.attack(enemy)
Index += 1 # Move on to the next enemy to attack
or just use
while True:
enemies = hero.findEnemies()
for enemy in enemies:
while enemy.health > 0:
hero.attack(enemy)
@EpicCoder999 thanks for all this help. I appreciated very much to read all of this Thanks very much. Somehow I got just unlucky that I could not answer anymore.