Grappeling hook system game


So I’m making a game, in it, there is a little guy who has a grappling hook of sorts. First, you should play the demo SWF I have attached. w,a,s,d to move, click to shoot the hook, and the rope will follow (its a lineTo(); from the guy to the flying hook.) What would be the best way to, once the rope is anchored in a wall or ceiling, have it “catch” on other walls or platforms. So, to see what I mean, shoot the ceiling, then walk under a platform, if it was real life, the rope would catch on the platform and bend under the platform, know what I mean?

What would be the best way to achieve something like that?