Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17ajf by
Grid/Grid.h
- Committer:
- el17ajf
- Date:
- 2019-04-24
- Revision:
- 36:c854f1f51f43
- Parent:
- 29:d59fbe128d1f
- Child:
- 41:91b0c73b9e02
File content as of revision 36:c854f1f51f43:
#ifndef GRID_H #define GRID_H #include "Tetromino.h" /** * Grid class * @brief Abstracts away access to a height x width 2d array, used to store * the 'landed' tetrominos. */ class Grid { public: /** * @param tetromino A Tetromino to place on this grid * @returns A boolean value representing if the tetromino * could fit in the grid * @see Tetromino */ bool isSpaceForTetromino(Tetromino tetromino); /** * @brief Commit a tetromino into the grid, setting values to true where * it overlaps the grid, updating the grid and clearing rows if needed * @param tetromino The tetromino to place * @returns The number of rows cleared by placing the tetromino on the grid * @see Tetromino */ int placeTetromino(Tetromino tetromino); /** * @brief Use the Graphics functions to draw a block for every value * in the grid * @see Graphics::Game::drawBlock */ void draw(); /** * @brief Create an empty grid */ Grid(); /** * The amount of space for hidden blocks at the top of the screen */ const static int HIDDEN_HEIGHT = 4; /** * The full height of the grid in blocks, including the hidden area */ const static int GRID_HEIGHT = 24; /** * The width of the grid in blocks */ const static int GRID_WIDTH = 10; private: int checkForLines(); void moveDownIfNeeded(); void shiftDownFrom(int row); bool grid[GRID_WIDTH][GRID_HEIGHT]; bool isSpaceForBlock(Block block); }; #endif