Hi guys, I am making a snake-like game.
I have a head and multiple body parts that move similar to slither.io.
The movement of snake is also similar to slither.io.
My game mechanic is different, where i encourage players to collide with their own snake body.
When they do so, an irregular circle is made.
Is there any possible way to obtain the all the game objects within that “irregular circle?”
What this actually does is doing is testing each triangle that is formed with the origin if it contains the point or not. Since we toggle the inside state each time we find another triangle we get the proper result. This is the same reason why summing the signed area of all those triangles give you the right surface area. See my gif animations
So if a point falls in a region that is actually outside the polygon, the point would be inside two triangles (one positive, one negative) so it is properly detected as being outside.
I’ve posted those images in a comment on this question about calculating the area of a polygon.