September 2018
Intermediate to advanced
328 pages
9h 10m
English
Rather than have confusing magic numbers sprinkled throughout the code base, I opted for a header file containing the constants we'll be using (constants.h). The contents of this file are shown here:
#ifndef TETRIS_CONSTANTS_H#define TETRIS_CONSTANTS_Hnamespace Constants { const int BoardColumns = 10; const int BoardHeight = 720; const int BoardRows = 20; const int BoardWidth = 360; const int Offset = BoardWidth / BoardColumns; const int PieceSize = 4; const int ScreenHeight = BoardHeight + 50;}#endif // TETRIS_CONSTANTS_H
The #ifndef statement in the first line of the file is an #include guard, which prevents the header file from being included multiple times during compilation. These guards are used in all of the application's ...
Read now
Unlock full access