# [GAMEPLAY] Detect closed polygon?

This topic is 2475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi Guys,

I have a game that is played on a grid, it's kind of a strategy game. Each time the player defeats an enemy he gains control of the enemies tile. The goal is to "lasso" off sections of the grid for a score multiplier.

So, my question is, if i have a list of points, how can i check if those points make an enclosed area or not? I can't just check if the point is in the list already or not as i don't want a straight line to be considered an enclosed area.

There is also a rare condition where trough the use of a certin character the player may be able to teleport, so the list of owned points might not be contigous... But if that's too hard to implement i might end up scratching it.

Can anyone help point me in the right direction on this?

Thanks
~Dave

##### Share on other sites
Flood fill the enemy tiles from their base or something, all tiles you didnt reach are surrounded by other types of tiles.

##### Share on other sites
Don't know how efficient it would be but maybe some kind of path finding thing. If each point is right next to each other and you have an enclosed shape you should be able to start at some point and eventually return to it. The shortest loop gives you the smallest enclosed area while the longest gives you the biggest. And I think you might want to start another path finding attempt at points which would branch out.

##### Share on other sites
kseh,

I did something similar, bsically made sure that there is at least one point in the list that overlaps, then that the list has at least one point that has a different x and y from the overlapping points. This works really well. Not so much for my special case, but with some modifying i'm sure it will work. Thanks for the suggestions guys!

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633731
• Total Posts
3013582
×