# Board game input, irregular board

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

## Recommended Posts

##### Share on other sites
Quote:
The color method would probably be ok. Another option would be to perform point-in-poly tests for each of the board cells (I have code for the 'point in non-convex poly' test that I can post if it would be helpful).

##### Share on other sites
I'm not horrible familiar with point-in-poly, but given that each of these spaces are REALLY irregular, I'm going to guess it'd be more trouble than it's worth.

If it helps, I'm working on recreating the board game Diplomacy... mostly as a personal exercise.

##### Share on other sites
you mention that you already have some kind of board structure that indicates 'sector' connectivity, how are you doing that? perhaps it could be useful in determining cursor clicks as well?

You could simply judge selection by distance of the cursor to the center of each sector (ignoring the irregular borders), just have the closest one light up or something to indicate what will be selected upon click, to avoid confusing the user with the 'fuzzy' borders.

##### Share on other sites
I'd rather stick with the color thing than do it as a distance/radius thing... that's pretty much bounding boxes (circles rather), and quite a bit less accurate than the color map.

##### Share on other sites
One way to do this is to make an image map.

In an image map the shapes in the map are defined as corner points using 0,0 as the upper left. You can use these points to build a list of shapes then find if the point of the mouse click is in a shape.

To optimize this a bit if you have a lot of shapes and peroformance suffers is to use a grid. Split your board into 4 or more sections. Then if the mouse click is in the upper left section you only have to check the shapes in that section for intersection. If you board is really irregular you will have shapes in more then one grid.

##### Share on other sites
...

+1 vote for the colour method. Really.

##### Share on other sites
Quote:
 Original post by NvrEndrI'm not horrible familiar with point-in-poly, but given that each of these spaces are REALLY irregular, I'm going to guess it'd be more trouble than it's worth. If it helps, I'm working on recreating the board game Diplomacy... mostly as a personal exercise.

You could use the depth buffer. If your using a top down view, set orthographic projection, from -10 to 10 in the Z dimension, and let each area's depth be dependent on it index. If i remember rightly, diplomacy has about 30 sections. Alternatively, you could break each irregular poly into two or more convex polys, which there are algorithms for, (although I've only read about them, not tried them). Then you could use the old fashioned point-in-poly test, which is basically done by drawing lines from the point to each corner, measuring the angle between these lines, and adding them up. As the point gets closer to the interior of the shape, the total of the angles approaches 360 degrees.

##### Share on other sites
The more I think about it, the more the color mask method makes sense. I've been working on it a little over the last day or so and I've made some progress towards making it work, so I think I'm going to stick with that.

Also, I'm considering (eventually) implementing a way to move the camera around... and at that point I'll be able to just manipulate the mask the same way I manipulate the background that's shown and still pull pixels that way.

Thanks for the advice, I'm thinking I'll look into one of the mentioned methods when it comes time to figure collision detection for the rest of the implementation (being able to click on an arrow or something that represents an order, etc).

##### Share on other sites
I love the colour map idea and has given me some idea's for my own possible project.

A couple years or so back I was looking to turn a board-game into a computer game, but I do was having problems with extreme irregularly shaped places on the board. I also didn't want to go out creating all the correctly shaped polygons for it either which ruled out the poly-intersection method. In the end I didn't go through with it, as it was just going to be a little game for me and my friends as the board game itself takes forever to set up.

Love visiting these forums, never know what snippets of good idea's you'll come out with.

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 12
• 12
• 9
• 14
• 10
• ### Forum Statistics

• Total Topics
632655
• Total Posts
3007670
• ### Who's Online (See full list)

There are no registered users currently online

×