![](/static/8d95373c/assets/icons/icon-96x96.png)
![](https://programming.dev/pictrs/image/c61dfed6-ab5d-4d8a-a30e-44002da3bd18.webp)
Adding to this: if you can’t use a polygon library, it’s quite easy to check if a point is inside a polygon. Just count the number of polygon edges is above the point (have a separate count for each polygon).
If the number is odd, then the point is inside the polygon. If it’s even, then it’s outside.
If there are multiple candidate polygons (which will happen with A in the example), pick the one with the closest edge to the point. Alternatively, pick the smallest polygon.
See ray casting algorithm in this page: https://en.wikipedia.org/wiki/Point_in_polygon
Just beware of floating point precision when implementing the algoritm.
But use a polygon library first and foremost.
Microsoft has already lost the console wars, and now it starts to look like they might even lose the PC wars. Is there any future for Microsoft gaming? It feels like the only thing they got going for them is Call of Duty.