Jump to content
  • Advertisement
Sign in to follow this  
uglybdavis

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

If you intended to correct an error in the post then please contact us.

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 this post


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

Share this post


Link to post
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 this post


Link to post
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!