Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

I need help with Village Guard


hey i need some help. here is my code


leftEnemy = self.findNearestEnemy()
if leftEnemy:
# Now move to the right entrance.
# Use "if" to attack if there is an enemy.
self.moveXY(60, 34)  
self.moveXY(35, 34)


Help us help you by reading the FAQ on how to format your code properly and the supply relating information


Your code does this:

Find nearest enemy.
If there is an enemy, attack enemy twice.
Move to the right position.
Move to the left position.

You need to find the nearest enemy from each X. If I were you, I would reset the level, then use the same technique to find rightEnemy that the default code uses to find leftEnemy.