Hey guys sorry to bug you but I can’t figure this one out. My code seems to be right but it says I am not defining x
. Here is my code.
while True:
newX = hero.pos.x
newY = hero.pos.y
enemy = hero.findNearestEnemy()
if enemy and hero.distanceTo(enemy) < 10:
# Subtract 10 from x to move left.
hero.moveXY(x - 10, y)
# Use moveXY to move to the new x, y position.
hero.moveXY(newX, newY)
pass
else:
# Add 10 to x to move right.
hero.moveXY(x + 10, y)
# Use moveXY to move to the new x, y position.
hero.moveXY(newX, newY)
pass
Help would be appreciated
Thanks!