Hello guys. I have recently attempted the Goalkeeper level, and after some time, I managed to succeed the level. However, I can’t seem to get the bonus.
Code
var friends = hero.findFriends();
while(true) {
for (var friendIndex = 0; friendIndex < friends.length; ++friendIndex) {
var friend = friends[friendIndex];
var ball = hero.findNearest(hero.findByType("ball"));
hero.command(friend, "move", {"x": 15, "y": ball.pos.y});
if (ball.pos.y > friend.pos.y) {
hero.command(friend, "move", {"x": 15, "y": ball.pos.y+1});
} else {
hero.command(friend, "move", {"x": 15, "y": ball.pos.y-1});
}
}
}
For those who use Python
friends = hero.findFriends()
while True:
for friend in friends:
friend = friends[friendIndex]
ball = hero.findNearest(hero.findByType("ball"))
hero.command(friend, "move", {"x": 15, "y": ball.pos.y})
if ball.pos.y > friend.pos.y:
hero.command(friend, "move", {"x": 15, "y": ball.pos.y+1})
else:
hero.command(friend, "move", {"x": 15, "y": ball.pos.y-1})
I will be able to accept help in either JavaScript of Python
Could any of you help?
Thanks