The GameGrid class
Finally, the GameGrid
class is quite simple. It keeps track of the squares on the game board. The gridArea
field is the portion of the total client area that is occupied by the grid:
GameGrid.h
const int Rows = 20, Cols = 10; class GameGrid { public: GameGrid(Rect gridArea); void ClearGameGrid(); Color* operator[](int row) {return gameGrid[row];} void InvalidateSquare(Window* windowPtr, int row, int col, Size offsetSize); void DrawGameGrid(Graphics& graphics, bool inverse) const; void DrawSquare(Graphics& graphics, int row, int col, Color penColor, Color brushColor, Size offsetSize = ZeroSize) const; Rect GridArea() const {return gridArea;} private: Rect gridArea; Color gameGrid[Rows][Cols]; };
When called by the TetrisWindow
constructor, the grid area will be set to (0, 20, 100, 100) units, placing it in the lower 80 percent of...