Line circle collisions

Hey people

been making a physics based game and need some line collisions with circles. Here is what I came up with today (this isn’t the game its just a new approach to the collisions which weren’t so good previously, before I kind of rotated the axis which meant I could only do it one sided but back to the point)

http://www.kitegallery.net/v/misc/Slideth/Sam/line+circle+collisions.swf.html

The only problem is that when the ball collides with the lines sometimes there is an overlap between the balls and the lines and the ball gets stuck.

I been thinking about the maths for the last hour and trying to work out how to get the ball to appear at the closest point on the edge of the line to where it is whenever it is overlapped…

I know I need to use the angle of the wall and presumably the distances from the nodes to the ball and stuff. Anyone got any clues lol my brain is fried.

here is a link to the actual game. the things may look ok but bounce to low and you’ll fall through which is not good

http://www.kitegallery.net/v/misc/Slideth/Sam/Gball.swf.html