Jump to content

  • Log In with Google      Sign In   
  • Create Account


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

  • You cannot reply to this topic
3 replies to this topic

#1 uglybdavis   Members   -  Reputation: 901

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

Sponsor:

#2 Waterlimon   Crossbones+   -  Reputation: 2416

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


#3 kseh   Crossbones+   -  Reputation: 1931

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.

#4 uglybdavis   Members   -  Reputation: 901

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