September 2018
Intermediate to advanced
328 pages
9h 10m
English
The piece, or Tetrimino, is the element that can be moved and rotated on the board. There are seven kinds of Tetriminos — each is represented by a letter and has a corresponding color:

We need a way to define each piece in terms of shape, color, and current orientation. Each piece has four different orientations (at 90 degree increments), which results in 28 total variations for all pieces. The color doesn't change, so that only needs to be assigned once. With that in mind, let's first take a look at the header file (piece.h):
#ifndef TETRIS_PIECE_H#define TETRIS_PIECE_H#include <SDL2/SDL.h> ...
Read now
Unlock full access