![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Tetris for the RA8875, derived from another users implementation.
Fork of Tetris by
Tetris, adapted to the RA8875 graphics library and display.
As currently implemented, this version is defined for the 800x480 display. A number of macros can adapt it for other screen resolutions.
Further, while presently configured for landscape mode, it should be fairly easy to reconfigure it for portrait mode.
Diff: main.cpp
- 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