Tetris game on mikroTFT touchscreen and LPC1768

Dependencies:   Tetris

Dependents:   Tetris

main.cpp

Committer:
sergun2311
Date:
2017-03-03
Revision:
2:6b6986c3d2bd
Parent:
1:b4aa36ae11ac
Child:
4:107d1d5a642e

File content as of revision 2:6b6986c3d2bd:

#include "mbed.h"
#include <ctime>
#include "playGround.h"
#include "Block.h"
#include "Field.h"

#define SPEED 100

int main()
{
    int score = 0;
    bool flag;
    clock_t start_s;
    TFTInit();
    drawMap();
    while (1) {
        Block NewBlock;
        flag = false;
        drawMap();
        drawScore(score);
        drawNextBlock(NewBlock);
        while( !flag ) {
            drawMap();
            drawBlock(NewBlock);
            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 = true;
            } else {
                clrBlock(NewBlock);
                NewBlock.y += 1;
                drawBlock(NewBlock);
            }
        }
        score += checkLine();
        clrNextBlock(NewBlock);
        if ( checkGameOver() )
            break;
    }
    gameOver(score);
}