September 2018
Intermediate to advanced
328 pages
9h 10m
English
The first section of code defines the constructor of the Piece class and the draw() function:
#include "piece.h"using namespace Constants;Piece::Piece(Piece::Kind kind) : kind_(kind), column_(BoardColumns / 2 - PieceSize / 2), row_(0), angle_(0) {}void Piece::draw(SDL_Renderer *renderer) { switch (kind_) { case I: SDL_SetRenderDrawColor(renderer, /* Cyan: */ 45, 254, 254, 255); break; case J: SDL_SetRenderDrawColor(renderer, /* Blue: */ 11, 36, 251, 255); break; case L: SDL_SetRenderDrawColor(renderer, /* Orange: */ 253, 164, 41, 255); break; case O: SDL_SetRenderDrawColor(renderer, /* Yellow: */ 255, 253, 56, 255); break; case S: SDL_SetRenderDrawColor(renderer, /* Green: */ 41, 253, 47, 255); break;Read now
Unlock full access