September 2018
Intermediate to advanced
328 pages
9h 10m
English
The Board contains instances of the Piece class and needs to detect collisions among the pieces, when rows are filled, and when the game is over. Let's start with the contents of the header file (board.h):
#ifndef TETRIS_BOARD_H#define TETRIS_BOARD_H#include <SDL2/SDL.h>#include <SDL2/SDL2_ttf.h>#include "constants.h"#include "piece.h"using namespace Constants;class Board { public: Board(); void draw(SDL_Renderer *renderer, TTF_Font *font); bool isCollision(const Piece &piece) const; void unite(const Piece &piece); private: bool isRowFull(int row); bool areFullRowsPresent(); void updateOffsetRow(int fullRow); void displayScore(SDL_Renderer *renderer, TTF_Font *font); bool cells_[BoardColumns][BoardRows]; int currentScore_; ...Read now
Unlock full access