Dance-off how to beat?

just for fun when i was stuck(i can’t post code) i used to kill all heros with the runesword

1 Like

All concepts are indeed taught but are never used like this. (at least not that I can recall)

The new location I used is +5 of the new entity to stay in sync.I found IF statements useless in this level as you don’t know any conditions

1 Like

that is my code it is sometimes work fine but can not work great all the time


while True:
    Friends = hero.findFriends()
    friendIndex = 0
    minidistance = 999
    closetFriend = None
    if len(Friends) > friendIndex:
        friend = Friends[friendIndex]
        if hero.distanceTo(friend) < minidistance:
            closetFriend = friend
            minidistance = hero.distanceTo(friend)
        friendIndex += 1
    
    while closetFriend:
        if closetFriend.pos.y > hero.pos.y:
            hero.moveXY(closetFriend.pos.x, closetFriend.pos.y - 6)
        elif closetFriend.pos.y < hero.pos.y:
            hero.moveXY(closetFriend.pos.x, closetFriend.pos.y + 6)

I will say the same as what I did in the other topic:
Well done for completing the level, but please could you not post working code. It ruins it for others.
So could you delete it (edit your post and delete the part with the code) and thank you for giving the advice, you can keep that part. It’s just that it’s better to help people understand without telling them the answer.
Thanks
Danny