Tetris game on mikroTFT touchscreen and LPC1768

Dependencies:   Tetris

Dependents:   Tetris

Revision:
1:b4aa36ae11ac
Parent:
0:645509d95b8d
Child:
2:6b6986c3d2bd
--- a/main.cpp	Mon Feb 20 14:14:30 2017 +0000
+++ b/main.cpp	Sat Feb 25 23:52:28 2017 +0000
@@ -2,32 +2,45 @@
 #include <ctime>
 #include "playGround.h"
 #include "Block.h"
+#include "Field.h"
 
-#define SPEED 10
+#define SPEED 100
 
 int main()
 {
-    int flag;
+    int score = 0;
+    bool flag;
     clock_t start_s;
     TFTInit();
     drawMap();
     while (1) {
         Block NewBlock;
-        flag = 0;
+        flag = false;
         drawMap();
-        while(flag == 0) {
+        while( !flag ) {
             drawMap();
             drawBlock(NewBlock);
-            start_s =clock();
+            start_s = clock();
             while( start_s + SPEED > clock() ) {
+                if ( TouchStatus() )    {
+                    clrBlock(NewBlock);
+                    NewBlock = doGest(NewBlock);
+                    drawBlock(NewBlock);
+                    wait_ms(50);
+                }
             }
             if ( NewBlock.CheckBottom() ) {
                 saveToField(NewBlock);
-                flag = 1;
+                flag = true;
             } else {
                 clrBlock(NewBlock);
                 NewBlock.y += 1;
+                drawBlock(NewBlock);
             }
         }
+        score += checkLine();
+        if ( checkGameOver() )
+            break;
     }
+    gameOver(score);
 }
\ No newline at end of file