Sign in to follow this  
NvrEndr

Board game input, irregular board

Recommended Posts

Hey guys, I have a quick question on how best to go about collecting and dealing with input in a board game setting. The biggest problem is that the 'spaces' on the board are irregularly shaped, placed, colored, and connected to each other. I've already built the board structure, so each space is aware of what it's adjacent to, etc. What I'm working with now is an image of the board and how to register which space the user clicks on. I'd really like to figure out the "right" way to go about this... but as of right now my gut reaction is this: Create a mask of the board (which I already have from my first attempt at this project a couple years ago), with each space being a different color. Then when the user clicks to go find that pixel, determine its color, and match it to a list of colors --> spaces. I'd love your input (haha) on the best way to go about this. Thanks!

Share this post


Link to post
Share on other sites
Quote:
Original post by NvrEndr
Hey guys, I have a quick question on how best to go about collecting and dealing with input in a board game setting. The biggest problem is that the 'spaces' on the board are irregularly shaped, placed, colored, and connected to each other. I've already built the board structure, so each space is aware of what it's adjacent to, etc. What I'm working with now is an image of the board and how to register which space the user clicks on. I'd really like to figure out the "right" way to go about this... but as of right now my gut reaction is this:

Create a mask of the board (which I already have from my first attempt at this project a couple years ago), with each space being a different color. Then when the user clicks to go find that pixel, determine its color, and match it to a list of colors --> spaces.

I'd love your input (haha) on the best way to go about this.

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


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


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


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


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


Link to post
Share on other sites
Quote:
Original post by NvrEndr
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.


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


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


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this