• Advertisement
Sign in to follow this  

Designing Movement On A Board Game

This topic is 4344 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

I'm developing a board game. Here's what the board looks like: http://brandontom.com/images/random/game-board.gif The 'X' represents a game piece. Pieces can move around the board in three directions: http://brandontom.com/images/random/game-board2.gif The directions are indicted by the red, green, and blue lines. What I'm trying to figure out the best way to design the movement. Basically this is what I was thinking (I said 'was' because it's a TERRIBLE idea): For each direction there are seven rows. I was going to create three classes that represent the three directions and then create objects that represent the rows. There would be 21 rows in all. Then I'd create a board space object. Each board space is associated with three rows. From there I'd populate the rows with board spaces and that's the general set up. How valid movement would be determined: From there all I'd have to do to figure out the movement was valid was to see if the two board spaces (the one being move to and the one being moved from) have a matching axis, then the move is valid. This tactic looks like it's going to suck. It's totally ineloquent. As you can imagine, there's a lot of duplicate code which is always a sign of disaster I need a new strategy and a new inspiration. Where am I going wrong here?

Share this post


Link to post
Share on other sites
Advertisement
Why don't you use a straight forward design:

a board which has just fields and has a function to determine if two fields are adjacent, which should be easy enough be determined by some way of circle function, as all fields you can move too lie on a circle around your field with a distance of 1 field...(if you have the centre point of each field as you draw it, that is it)...

Share this post


Link to post
Share on other sites
See your table as a 2D matrix. You can set all cells in a 2D coordinate system (xOy). For every row you have to remember length and offset. Offset is used when first table cell does not overlay the first matrix cell for a certain row.

From there you only have basic moves over a chess table which is pretty simple to define.

Share this post


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

  • Advertisement