September 2018
Intermediate to advanced
328 pages
9h 10m
English
The first section of code defines the constructor of the Board class and the draw() function:
#include <sstream>#include "board.h"using namespace Constants;Board::Board() : cells_{{ false }}, currentScore_(0) {}void Board::draw(SDL_Renderer *renderer, TTF_Font *font) { displayScore(renderer, font); SDL_SetRenderDrawColor( renderer, /* Light Gray: */ 140, 140, 140, 255); for (int column = 0; column < BoardColumns; ++column) { for (int row = 0; row < BoardRows; ++row) { if (cells_[column][row]) { SDL_Rect rect{ column * Offset + 1, row * Offset + 1, Offset - 2, Offset - 2 }; SDL_RenderFillRect(renderer, &rect); } } }}
The Board constructor initializes the values of the private cells_ and currentScore_ variables ...
Read now
Unlock full access