I want to create a polygon around an image for better collision detection. Right now, I’m just using the full rectangle around the sprite.
For some of the larger sprites, this isn’t good enough. A circle wouldn’t really work either because of all the tentacles. What I would like to do is define a generic polygon around them. Unfortunately, I don’t know precisely how to do this.
I figure that the first step is to do Breadth First Search from the corner of the image to find all the non-transparent points at the edge of the image. To make sure I find ALL of them, I’ll wrap a 1-pixel box of transparency around the image (just in case any of the tentacles touch the edge and cut off some of the other tentacles from the Breadth First Search).
Now I could use those points to somehow define a polygon, but it might have 1000 vertices connected by 1-pixel-long lines, which is clearly bad. How do I determine which points to use in the polygon?