September 2018
Intermediate to advanced
328 pages
9h 10m
English
The second section contains the logic to move or rotate the piece and determine its current location:
void Piece::move(int columnDelta, int rowDelta) { column_ += columnDelta; row_ += rowDelta;}void Piece::rotate() { angle_ += 3; angle_ %= 4;}bool Piece::isBlock(int column, int row) const { static const char *Shapes[][4] = { // I { " * " " * " " * " " * ", " " "****" " " " ", " * " " * " " * " " * ", " " "****" " " " ", }, // J { " * " " * " " ** " " ", " " "* " "*** " " ", " ** " " * " " * " " ", " " " " "*** " " * ", }, ... }; return Shapes[kind_][angle_][column + row * PieceSize] == '*';}int Piece::getColumn() const { return column_;}int Piece::getRow() const { return row_;}
The move() function ...
Read now
Unlock full access