After adding the Board class

As the starting point one should start with four functions; one to draw, one to get the size of the field, and two to initialize the data. The first initialization function is for new games. The second is for those times the playing field changes. (Actually for non-solitare games, the Board class only needs to initialized once in its lifetime.)

The data variable that the Board class will start with is a pointer to a Rectangle class, *places. (CRect in Microsoft IDE.) Since the Board will be re-sized when different game playing options are selected, pointers will allow the board information to be destroyed and recreated on the fly. Clean-up is nothing out of the ordinary, so the Board class's destructor can be in charge of that.
The other starting variable is a integer to hold the size information. This is to avoid all the sizeof()/sizeof(Rectangle) hoops to jump through to get pointer array information. I recommend just storing the length of the side.

For right now, the drawing function for the class just can draw the rectangles that places point to. This will suffice as a place-holder until the rest of the game's variables are added. A single loop will be all that is required. Just assert() that there is a valid pointer before drawing random pointers.

No comments: