Sound update
Dependencies: 4DGL-uLCD-SE Physac-MBED PinDetect SDFileSystem mbed-rtos mbed
tetris/Board.h@19:6d9bee043ede, 22 months ago (annotated)
- Committer:
- jstephens78
- Date:
- Sun Dec 04 23:31:28 2022 +0000
- Revision:
- 19:6d9bee043ede
- Parent:
- Tetris/Board.h@15:e9f3b72b7486
- Child:
- 26:163d7ca8c42d
Tetris compiles now
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jsanchez307 | 15:e9f3b72b7486 | 1 | #ifndef _BOARD_ |
jsanchez307 | 15:e9f3b72b7486 | 2 | #define _BOARD_ |
jsanchez307 | 15:e9f3b72b7486 | 3 | |
jsanchez307 | 15:e9f3b72b7486 | 4 | // ------ Includes ----- |
jsanchez307 | 15:e9f3b72b7486 | 5 | |
jsanchez307 | 15:e9f3b72b7486 | 6 | #include "Pieces.h" |
jsanchez307 | 15:e9f3b72b7486 | 7 | |
jsanchez307 | 15:e9f3b72b7486 | 8 | // ------ Defines ----- |
jsanchez307 | 15:e9f3b72b7486 | 9 | |
jsanchez307 | 15:e9f3b72b7486 | 10 | #define BOARD_LINE_WIDTH 6 // Width of each of the two lines that delimit the board |
jsanchez307 | 15:e9f3b72b7486 | 11 | #define BLOCK_SIZE 6 // Width and Height of each block of a piece |
jsanchez307 | 15:e9f3b72b7486 | 12 | #define BOARD_POSITION 50 // Center position of the board from the left of the screen |
jsanchez307 | 15:e9f3b72b7486 | 13 | #define BOARD_WIDTH 10 // Board width in blocks |
jsanchez307 | 15:e9f3b72b7486 | 14 | #define BOARD_HEIGHT 20 // Board height in blocks |
jsanchez307 | 15:e9f3b72b7486 | 15 | #define MIN_VERTICAL_MARGIN 8 // Minimum vertical margin for the board limit |
jsanchez307 | 15:e9f3b72b7486 | 16 | #define MIN_HORIZONTAL_MARGIN 20 // Minimum horizontal margin for the board limit |
jsanchez307 | 15:e9f3b72b7486 | 17 | #define PIECE_BLOCKS 5 // Number of horizontal and vertical blocks of a matrix piece |
jsanchez307 | 15:e9f3b72b7486 | 18 | |
jsanchez307 | 15:e9f3b72b7486 | 19 | |
jsanchez307 | 15:e9f3b72b7486 | 20 | // -------------------------------------------------------------------------------- |
jsanchez307 | 15:e9f3b72b7486 | 21 | // Board |
jsanchez307 | 15:e9f3b72b7486 | 22 | // -------------------------------------------------------------------------------- |
jsanchez307 | 15:e9f3b72b7486 | 23 | |
jsanchez307 | 15:e9f3b72b7486 | 24 | class Board |
jsanchez307 | 15:e9f3b72b7486 | 25 | { |
jsanchez307 | 15:e9f3b72b7486 | 26 | public: |
jsanchez307 | 15:e9f3b72b7486 | 27 | |
jsanchez307 | 15:e9f3b72b7486 | 28 | Board (Pieces *pPieces, int pScreenHeight); |
jsanchez307 | 15:e9f3b72b7486 | 29 | |
jsanchez307 | 15:e9f3b72b7486 | 30 | int GetXPosInPixels (int pPos); |
jsanchez307 | 15:e9f3b72b7486 | 31 | int GetYPosInPixels (int pPos); |
jsanchez307 | 15:e9f3b72b7486 | 32 | bool IsFreeBlock (int pX, int pY); |
jsanchez307 | 15:e9f3b72b7486 | 33 | bool IsPossibleMovement (int pX, int pY, int pPiece, int pRotation); |
jsanchez307 | 15:e9f3b72b7486 | 34 | void StorePiece (int pX, int pY, int pPiece, int pRotation); |
jsanchez307 | 15:e9f3b72b7486 | 35 | int DeletePossibleLines (); |
jsanchez307 | 15:e9f3b72b7486 | 36 | bool IsGameOver (); |
jsanchez307 | 15:e9f3b72b7486 | 37 | |
jsanchez307 | 15:e9f3b72b7486 | 38 | private: |
jsanchez307 | 15:e9f3b72b7486 | 39 | |
jsanchez307 | 15:e9f3b72b7486 | 40 | // enum holds no value besides the described properties |
jsanchez307 | 15:e9f3b72b7486 | 41 | enum { POS_FREE, POS_FILLED }; // POS_FREE = free position of the board; POS_FILLED = filled position of the board |
jsanchez307 | 15:e9f3b72b7486 | 42 | int mBoard [BOARD_WIDTH][BOARD_HEIGHT]; // Board that contains the pieces |
jsanchez307 | 15:e9f3b72b7486 | 43 | Pieces *mPieces; |
jsanchez307 | 15:e9f3b72b7486 | 44 | int mScreenHeight; |
jsanchez307 | 15:e9f3b72b7486 | 45 | |
jsanchez307 | 15:e9f3b72b7486 | 46 | void InitBoard(); |
jsanchez307 | 15:e9f3b72b7486 | 47 | void DeleteLine (int pY); |
jsanchez307 | 15:e9f3b72b7486 | 48 | }; |
jsanchez307 | 15:e9f3b72b7486 | 49 | |
jsanchez307 | 15:e9f3b72b7486 | 50 | #endif |