Setting "positions" to an array of object[6][6]

Hi, im currently making a match 3 type of game and I'm stuck at this point. I can randomly fill in my 6x6 array, which is my gameBoard, but the positions im setting are not related to my array and I would like to know a simple way to do so. Here are the positions im trying to 'link', if you will :

1
2
3
4
5
6
7
8
const string validPositions[36] = { "A1", "A2", "A3", "A4", "A5", "A6",
						    "B1", "B2", "B3", "B4", "B5", "B6",
						    "C1", "C2", "C3", "C4", "C5", "C6",
						    "D1", "D2", "D3", "D4", "D5", "D6",
						    "E1", "E2", "E3", "E4", "E5", "E6",
						    "F1", "F2", "F3", "F4", "F5", "F6" };



Then, in my object (which is filling the board) constructor, I assign a random index of this string to the object, easy part. But now, the program needs to know that "A1", for exemple, is the top left element in the 6x6 grid, and so on.

Thank you very much in advance, and if you need more code, please ask. Im currently working on recoding all of it that I got into much more cleaner code, as I learned alot during the 2 days leading me to this.

(P.S. : Sorry for Engrish :P)
Last edited on
Thinking about it, do I really need a position, as the index of the object array[6][6] is actually my position?

1
2
3
4
5
6
7
8
class Board
{
public:
...

private:
Gem gameBoard[6][6]; /* <----- Thinking this right here, using a [i][j] index would do it. (As this is already how my class is built) */
}


Tell me if I'm wrong.
Last edited on
Topic archived. No new replies allowed.