![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
All there but errors need fixing
Dependencies: mbed
Overview:
Rookie Tetris is a jigsaw style game based on the classic Tetris.
A block will appear at the top of the screen, you must move it (your options for movement are left, right and down - you cannot move up the board). The block will stop when it if placed either on the floor of the board or on-top of another block.
Your goal is to fill a complete row of the board with the blocks; when you do so the row will delete and the pattern above it will drop down. The game is over when your pattern is tall enough to reach to the top of the board!
Controls:
Use the joystick to move your block! Your block cannot move out of the parameters of the board.
Pot 2 controls the contrast of the screen.
Diff: TetrisGame/TetrisGame.cpp
- Revision:
- 20:ad685b35a1a4
- Parent:
- 19:2ad31dbd5d11
- Child:
- 21:6d4dd906edde
diff -r 2ad31dbd5d11 -r ad685b35a1a4 TetrisGame/TetrisGame.cpp --- a/TetrisGame/TetrisGame.cpp Wed Jun 03 12:14:47 2020 +0000 +++ b/TetrisGame/TetrisGame.cpp Wed Jun 03 12:47:33 2020 +0000 @@ -87,20 +87,14 @@ b = tetromino_pos.y; floor_hit_flag = 1; + + if (b <= 4) { + exit_game(lcd); + } printf("floor hit!\n"); } - // check if hit roof - else if (tetromino_pos.y <= 1) { - - floor_hit_flag = 0; - - printf("roof hit!\n"); - - exit_game(lcd); - - } // printf("wall collision\n"); @@ -132,6 +126,10 @@ b = tetromino_pos.y; floor_hit_flag = 1; + + if (b <= 4) { + exit_game(lcd); + } printf("blocks stacked!\n"); } @@ -141,8 +139,8 @@ void TetrisGame::cancel_line(N5110 &lcd) { int count; - for(int j=4; j<=42; j+=1) { - for(int i=19; i<=40; i++) { + for(int j=4; j<=46; j+=1) { + for(int i=20; i<=60; i++) { if (lcd.getPixel(i,j)==0) { // if the pixel is empty the counting stops and exits loop count=0; break; @@ -150,13 +148,13 @@ count ++; } } - if(count==41) { // if gets to end of line + if(count==61) { // if gets to end of line count = 0; - lcd.drawLine(19,j,40,j,0); // clear line + lcd.drawLine(20,j,60,j,0); // clear line printf("line canceled!\n"); // score++; - for(int x=19; x<=40; x++) { - for(int y=j; y>=0; y--) { + for(int x=20; x<=60; x++) { + for(int y=j; y>=4; y--) { lcd.setPixel(x,y,false); lcd.setPixel(x,y+1); // sets pixel to the one above printf("line dropped!\n");