when submitting the code it brings up an error
here’s my code
while True:
enemy = hero.findNearestEnemy()
friend = hero.findNearestFriend()
# Calculate x by adding friend.pos.x to enemy.pos.x
# Then divide by 2.
# Check the guide if you need more help!
x = (enemy.pos.x + friend.pos.x) / 2
# Now do the same for y
y = (hero.pos.y + friend.pos.y) / 2
# Move to the x and y coordinates you calculated.
x = ("tower".pos.x + peasant.pos.x) / 2
y = ("tower".pos.y + peasant.pos.y) / 2
change to
tower.pos.x
tower.pos.y
also, is this all your code?
ok will try thank you
1 Like
oh wait my mistake change
to moveXY(x,y)
you’re supposed to add enemy.pos.y
and friend.pos.y
and then divide by 2
thanks for everything, I figured out that all I had to do was the change code from this
x = (enemy.pos.x + friend.pos.x) / 2
# Now do the same for y
y = (hero.pos.y + friend.pos.y) / 2
to
x = (enemy.pos.x + friend.pos.x) / 2
# Now do the same for y
y = enemy.pos.y + friend.pos.y) / 2
thank you for your help
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.