September 2018
Intermediate to advanced
328 pages
9h 10m
English
The Game class contains the looping function that enables you to move pieces around the board with key presses. Here's the contents of the header file (game.h):
#ifndef TETRIS_GAME_H#define TETRIS_GAME_H#include <SDL2/SDL.h>#include <SDL2/SDL2_ttf.h>#include "constants.h"#include "board.h"#include "piece.h"class Game { public: Game(); ~Game(); bool loop(); private: Game(const Game &); Game &operator=(const Game &); void checkForCollision(const Piece &newPiece); void handleKeyEvents(SDL_Event &event); SDL_Window *window_; SDL_Renderer *renderer_; TTF_Font *font_; Board board_; Piece piece_; uint32_t moveTime_;};#endif // TETRIS_GAME_H
The loop() function contains the game logic and manages state based on events. The first two ...
Read now
Unlock full access