I'm developing a board game. Here's what the board looks like:
The 'X' represents a game piece. Pieces can move around the board in three directions:
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 to 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 (what would Kathy Sierra do?) I need a new strategy and a new inspiration. Where am I going wrong here?
[ March 30, 2006: Message edited by: Brandon Tom ]