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: Game/Game.cpp
- Revision:
- 9:3a7776a29a11
- Parent:
- 7:2e37bad816cb
- Child:
- 11:fba7d54fd36b
--- a/Game/Game.cpp Fri Mar 15 16:39:06 2019 +0000 +++ b/Game/Game.cpp Fri Mar 15 20:30:01 2019 +0000 @@ -16,11 +16,24 @@ } void Game::update() { - if (false /* Input::getLeft */) { + if (Input::buttonHit(Input::LEFT)) { if (grid.isSpaceForTetromino(currentTetromino.movedLeft())) { currentTetromino = currentTetromino.movedLeft(); } } + if (Input::buttonHit(Input::RIGHT)) { + if (grid.isSpaceForTetromino(currentTetromino.movedRight())) { + currentTetromino = currentTetromino.movedRight(); + } + } + if (Input::buttonHit(Input::UP)) { + if (grid.isSpaceForTetromino(currentTetromino.rotatedClockwise())) { + currentTetromino = currentTetromino.rotatedClockwise(); + } + } + if (Input::buttonHit(Input::DOWN)) { + dropCurrentTetromino(); + } } void Game::moveCurrentTetrominoDown() { @@ -33,7 +46,10 @@ } void Game::dropCurrentTetromino() { - + while (grid.isSpaceForTetromino(currentTetromino.movedDown())) { + currentTetromino = currentTetromino.movedDown(); + } + moveCurrentTetrominoDown(); } void Game::draw() {