I’m supposed to be in between my friends and the enemy, but the game keep saying the friends property is protected.
Here is my code: while True: enemy = hero.findNearestEnemy() friend = self.findFriends hero.moveXY(enemy.pos.x - friend.pos.x, enemy.pos.y - friend.pos.y)
Please review the instructions. The commented out code tells you what to do. Here they are in case you accidentally deleted them:
// Calculate x by adding friend.pos.x to enemy.pos.x
// Then divide by 2.
// Check the guide if you need more help!
// Now do the same for y
// Move to the x and y coordinates you calculated.
If you still need help, look in the Hints or ask me.
please tell me what is wrong i want to beat this level
while True:
billy= hero.findEnemies()
steve = hero.findFriends()
enemy = hero.findNearest(billy)
friend = hero.findNearest(steve)
enemy.pos.x == enemy.x
friend.pos.x == friend.x
enemy.pos.y == enemy.y
friend.pos.y == friend.y
# Calculate x by adding friend.pos.x to enemy.pos.x
# Then divide by 2.
# Check the guide if you need more help!
1 == (enemy.pos.x + friend.pos.x) / 2
# Now do the same for y
2 == (enemy.pos.y + friend.pos.y) / 2
# Move to the x and y coordinates you calculated.
hero.moveXY(1 , 2 )
and i think i found the problem in your code instead of naming your variables 1 and 2, name them x and y, because when you put 1 or 2 in the moveXY command, it thinks that you mean 1 and 2 as numbers, not as variables