[GAMEPLAY] Detect closed polygon?

Started by
2 comments, last by uglybdavis 12 years, 1 month ago
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
Advertisement
Flood fill the enemy tiles from their base or something, all tiles you didnt reach are surrounded by other types of tiles.

o3o

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.
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!

This topic is closed to new replies.

Advertisement