Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Skating on ice (klevintaph crusader)


what is wrong with the following code for the slippery ice patch?

        friends = hero.findFriends()
        goalPoint= Vector (78, 40)
        for friend in friends:
            if friend.pos.x < 50:
                hero.command(friend, "move", {'x':50, 'y':58})
            if friend.pos.y > 39:
                hero.command(friend, "move", {'x':50, 'y':38})
            if friend.pos.x < 78:
                goal = Vector.subtract(goalPoint, friend.pos)
                goal = Vector.normalize(goal)
                goal = Vector.multiply(goal, 10)
                # make a vector from the trap to you
                trapPos = {'x':72, 'y':56}
                danger = Vector.subtract(friend.pos, trapPos)
                danger = Vector.normalize(danger)
                danger = Vector.multiply (danger, 10)
                goal = Vector.add(goal, danger)
                moveToPos = Vector.add(friend.pos, goal)
                hero.command(friend, "move", moveToPos)