if statements are not inside the
for loop. You should indent both
if statements (more specifically, everything after the
enemy=enemies[enemyIndex] line) one level further.
Just in case, you should also change
enemy.health<=0 so you don’t get an infinite loop in case the enemy hits exactly zero health. Another simpler alternative would be to remove the
<= 0 check and simply de-indent the index increment so it runs after the loop has ended, e.g.:
enemyIndex = enemyIndex + 1
Another problem: you are never incrementing the index when the enemy type is
sand-yak, this will also get you an infinite loop as your loop will never advance past the given sand-yak.
Another problem: you only get a list of enemies at the very beginning of the simulation (
enemies = self.findEnemies()), it should be inside the loop instead so that you can find enemies that have spawned after the first game frame.
Another (possible) problem: you are only attacking enemies whose type is
"ogre". I think you want to attack everything that is not a sand-yak, so you can just replace
if enemy.type == "sand-yak": with an