Tetris game on mikroTFT touchscreen and LPC1768

Dependencies:   Tetris

Dependents:   Tetris

Revision:
0:645509d95b8d
Child:
1:b4aa36ae11ac
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Block.cpp	Mon Feb 20 14:14:30 2017 +0000
@@ -0,0 +1,40 @@
+#include "Block.h"
+#include "mbed.h"
+#include "playGround.h"
+#include "Piece.h"
+#include "Field.h"
+    
+Block::Block() {
+    form = rand() % 7;
+    angle = rand() % 4;
+    x = 4 + rand() % 2;
+    y = 0;
+}      
+
+Block::~Block() {
+    
+}
+     
+void Block::rotateLeft() {
+    angle--;
+}  
+
+void Block::rotateRight() {
+    angle++;
+}   
+
+bool Block::CheckBottom()
+{
+    int xx, yy;
+    for ( xx = 0 ; xx < 5 ; xx++ ) {
+        for (yy = 0 ; yy < 5 ; yy++ )  {        
+            if ( (Piece[form][angle][xx][yy] != 0)   
+                && (Field[y + yy - 1][x + xx - 2] != 0) &&
+                ( y + yy - 3 > 0 ) ) 
+                return 1; 
+            if ( (Piece[form][angle][xx][yy] != 0) && ( yy + y == 13 ) )          
+                return 1;
+        }
+    }
+    return 0;
+}