I am purely guessing here... I noticed that the balls are very, what's the word, "jittery" when they collide with a surface and I think that this may be the cause of getting "trapped". With most collision routines, like circles and circles, rectangles and circles etc, the routines "assume" that the objects are "solid" ie: defined by strict boundaries.
This is where I am guessing...
The drawn polygons are just a series of connected lines with a filled interior. The "surface" of the polygon is one pixel thick. Not what I would classify as "solid" per se. Combine the speed of the ball and the time it would take to calculate the collision with a line, the ball has already started moving "through" the line when it realizes that it's moved too far and tries to "jump" back. Now, multiply the events by many balls, and thus introducing "lag" and thus "allowing" the ball enough time to pass through the line... until it is presented with another line of the same polygon. It then bounces around within the polygon... That's my guess. Solution: Use "solid" shapes or write collision routines for each specific polygon.
This is where I am guessing...
The drawn polygons are just a series of connected lines with a filled interior. The "surface" of the polygon is one pixel thick. Not what I would classify as "solid" per se. Combine the speed of the ball and the time it would take to calculate the collision with a line, the ball has already started moving "through" the line when it realizes that it's moved too far and tries to "jump" back. Now, multiply the events by many balls, and thus introducing "lag" and thus "allowing" the ball enough time to pass through the line... until it is presented with another line of the same polygon. It then bounces around within the polygon... That's my guess. Solution: Use "solid" shapes or write collision routines for each specific polygon.
Logic is the beginning of wisdom.
Live long and prosper.
Live long and prosper.

