summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 47526c8..d897aa4 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -104,7 +104,6 @@ bool GameState::cellIsEmpty(Point* p){
return( p->x < GRID_WIDTH && p->x >= 0 && grid[p->y][p->x] == 0 );
}
-void GameState::pressRotate(){}
void GameState::pressDown(){
yspeed_ = 4;
}
@@ -139,3 +138,17 @@ void GameState::pressRight(){
}
piece_ = tmp;
}
+
+void GameState::pressRotate(){
+ Piece tmp = piece_;
+ tmp.rotate();
+ Point* p;
+ // Check if there's space to move to
+ tmp.initIterator();
+ while ( p = tmp.nextAbsBlockPos() ){
+ if(!cellIsEmpty(p)){
+ return;
+ }
+ }
+ piece_ = tmp;
+}