• Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a \$50 Amazon gift card. Click here to get started!

# [GAMEPLAY] Detect closed polygon?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1uglybdavis  Members   -  Reputation: 1050

Like
0Likes
Like

Posted 06 March 2012 - 09:01 AM

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

### #2Waterlimon  Crossbones+   -  Reputation: 3656

Like
0Likes
Like

Posted 06 March 2012 - 09:40 AM

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

o3o

### #3kseh  Crossbones+   -  Reputation: 2619

Like
1Likes
Like

Posted 06 March 2012 - 10:53 AM

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.

### #4uglybdavis  Members   -  Reputation: 1050

Like
0Likes
Like

Posted 06 March 2012 - 12:50 PM

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!

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS