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
Diff: Grid/Grid.h
- Revision:
- 36:c854f1f51f43
- Parent:
- 29:d59fbe128d1f
- Child:
- 41:91b0c73b9e02
diff -r d0d3ba96798a -r c854f1f51f43 Grid/Grid.h
--- a/Grid/Grid.h Tue Apr 23 17:22:56 2019 +0000
+++ b/Grid/Grid.h Wed Apr 24 08:06:29 2019 +0000
@@ -3,15 +3,55 @@
#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);
- void clear();
+
+ /**
+ * @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:
