Tetris game on mikroTFT touchscreen and LPC1768
Revision 4:107d1d5a642e, committed 2017-03-18
- Comitter:
- sergun2311
- Date:
- Sat Mar 18 14:45:16 2017 +0000
- Parent:
- 3:36de55e63fdf
- Commit message:
- Tetris V1
Changed in this revision
--- a/Block.cpp Sat Mar 11 19:50:03 2017 +0000 +++ b/Block.cpp Sat Mar 18 14:45:16 2017 +0000 @@ -3,11 +3,17 @@ #include "playGround.h" #include "Piece.h" #include "Field.h" +#include "Define.h" +#include <ctime> + +// Constructor of the object. Gives the random form and +// defines the position on the field Block::Block() -{ +{ + srand (clock()); if (nextForm > 6) - nextForm = rand() % 7; + nextForm = (rand() + 1) % 7; form = nextForm; nextForm = rand() % 7; angle = rand() % 4; @@ -15,10 +21,15 @@ y = -1; } +// Destructor of an object + Block::~Block() { } +// Check possibility of rotating of a block and +// rotate it if it is possible + void Block::rotateLeft() { if ( !CheckRotateLeft() ) { @@ -39,6 +50,9 @@ } } +// Check possibility of moving the block and +// moves it if it is possible + void Block::moveLeft() { if ( !CheckLeft() ) @@ -51,6 +65,11 @@ x++; } +// Check possibility to move block one level below. Checks both, frame and +// blocks on the field ( separately ). +// Returns 1 if it is not possible and +// 0 if it is possible. + bool Block::CheckBottom() { int xx, yy; @@ -67,6 +86,11 @@ return 0; } +// Check possibility to move block to the left. Checks both, frame and +// blocks on the field ( separately ). +// Returns 1 if it is not possible and +// 0 if it is possible. + bool Block::CheckLeft() { int xx, yy; @@ -83,6 +107,11 @@ return 0; } +// Check possibility to move block to the right. Checks both, frame and +// blocks on the field ( separately ). +// Returns 1 if it is not possible and +// 0 if it is possible. + bool Block::CheckRight() { int xx, yy; @@ -99,6 +128,11 @@ return 0; } +// Check possibility of rotation counter clockwise Checks both, frame and +// blocks on the field ( separately ). +// Returns 1 if it is not possible and +// 0 if it is possible. + bool Block::CheckRotateLeft() { int xx, yy; @@ -110,11 +144,16 @@ return 1; if ( (Piece[form][( abs(angle + 1) ) % 4][xx][yy] != 0) && (( xx + x == 1 ) || ( xx + x == MAXX + 1 )) ) return 1; - } + } } return 0; } +// Check possibility of rotation clockwise Checks both, frame and +// blocks on the field ( separately ). +// Returns 1 if it is not possible and +// 0 if it is possible. + bool Block::CheckRotateRight() { int xx, yy;
--- a/Block.h Sat Mar 11 19:50:03 2017 +0000 +++ b/Block.h Sat Mar 18 14:45:16 2017 +0000 @@ -1,25 +1,26 @@ #ifndef BLOCK_H #define BLOCK_H -class Block { - public: - Block(); - ~Block(); - int form; - int nextForm; - int angle; - int x; - int y; - bool Active; - void rotateLeft(); - void rotateRight(); - bool CheckBottom(); - bool CheckLeft(); - bool CheckRight(); - bool CheckRotateLeft(); - bool CheckRotateRight(); - void moveLeft(); - void moveRight(); +class Block +{ +public: + Block(); + ~Block(); + int form; + int nextForm; + int angle; + int x; + int y; + bool Active; + void rotateLeft(); + void rotateRight(); + bool CheckBottom(); + bool CheckLeft(); + bool CheckRight(); + bool CheckRotateLeft(); + bool CheckRotateRight(); + void moveLeft(); + void moveRight(); }; - + #endif \ No newline at end of file
--- a/Define.h Sat Mar 11 19:50:03 2017 +0000 +++ b/Define.h Sat Mar 18 14:45:16 2017 +0000 @@ -1,5 +1,22 @@ -extern const int MAXX = 10; -extern const int MAXY = 12; -extern const int PURPLE = 0x780F; -extern const int DARKGREY = 0x7BEF; -extern const int BLOCK_SIZE = 20; \ No newline at end of file +// +// GAME AND DESIGN PARAMETERS +// +#define MAXX 10 +#define MAXY 12 +#define BLOCK_SIZE 20 +#define BLACK 0 +#define SPEED 100 +#define SMALL_BLOCK_SIZE 8 +// +// COLOUR DEFINES +// +#define PURPLE 0x780F +#define DARKGREY 0x7BEF +#define BLACK 0 +#define Blue 0x001F +#define Green 0x07E0 +#define Red 0xF800 +#define Yellow 0xFFE0 +#define Orange 0xFD20 +#define GreenYellow 0xAFE5 +#define Magenta 0xF81F \ No newline at end of file
--- a/Field.cpp Sat Mar 11 19:50:03 2017 +0000 +++ b/Field.cpp Sat Mar 18 14:45:16 2017 +0000 @@ -1,14 +1,17 @@ #include "Field.h" #include "playGround.h" #include "Piece.h" +#include "Define.h" -#define BLACK 0 -#define MAXX 10 -#define MAXY 12 - +// Declearing and defining of the playground/field extern int Field[MAXY][MAXX] = {0}; -int checkLine() { +// Checking field for filled lines. If it is field +// it removes it with lines uppon it +// Returns Score equal to amount of removed lines, multipiled with 100 + +int checkLine() +{ int x, y, score = 0; bool status; for ( y = 0 ; y < MAXY ; y++ ) { @@ -24,7 +27,7 @@ for (xx = 0 ; xx < MAXX ; xx++ ) { Field[yy][xx] = Field[yy-1][xx]; } - + } } } @@ -33,15 +36,21 @@ return score; } +// Checks blocks on MAXX (top) layer. +// If there is any it retunrs TRUE ,else false + bool checkGameOver() { int x; for ( x = 0 ; x < MAXX ; x++ ) if ( Field[0][x] != BLACK ) return true; - return false; + return false; } +// Saves an object NewBlock to the field. +// Fills matrix with colors of the blocks + void saveToField(Block NewBlock) { int xx , yy;
--- a/Field.h Sat Mar 11 19:50:03 2017 +0000 +++ b/Field.h Sat Mar 18 14:45:16 2017 +0000 @@ -1,4 +1,5 @@ #include "Block.h" +#include "Define.h" extern int Field[MAXY][MAXX]; int checkLine();
--- a/Piece.cpp Sat Mar 11 19:50:03 2017 +0000 +++ b/Piece.cpp Sat Mar 18 14:45:16 2017 +0000 @@ -1,233 +1,230 @@ #include "Piece.h" +#include "Define.h" -#define Blue 0x001F -#define Green 0x07E0 -#define Red 0xF800 -#define Yellow 0xFFE0 -#define Orange 0xFD20 -#define GreenYellow 0xAFE5 -#define Magenta 0xF81F +// Defining of Pieces (Blocks/Shapes) +// Here is 7 types of PIECES, eack with 4 different angles +// and consists of matixes of colors, sized 5x5 const int Piece [ 7 ][ 4 ][ 5 ][ 5 ] = { - { - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, Blue, Blue, 0}, - {0, 0, Blue, Blue, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, Blue, Blue, 0}, - {0, 0, Blue, Blue, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, Blue, Blue, 0}, - {0, 0, Blue, Blue, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, Blue, Blue, 0}, - {0, 0, Blue, Blue, 0}, - {0, 0, 0, 0, 0} - } - }, - -// I - { { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {Green, Green, Green, Green, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, Green, 0, 0}, - {0, 0, Green, 0, 0}, - {0, 0, Green, 0, 0}, - {0, 0, Green, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {Green, Green, Green, Green, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, Blue, Blue, 0}, + {0, 0, Blue, Blue, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, Blue, Blue, 0}, + {0, 0, Blue, Blue, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, Blue, Blue, 0}, + {0, 0, Blue, Blue, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, Blue, Blue, 0}, + {0, 0, Blue, Blue, 0}, + {0, 0, 0, 0, 0} + } }, - { - {0, 0, Green, 0, 0}, - {0, 0, Green, 0, 0}, - {0, 0, Green, 0, 0}, - {0, 0, Green, 0, 0}, - {0, 0, 0, 0, 0} + +// I + { + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {Green, Green, Green, Green, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, Green, 0, 0}, + {0, 0, Green, 0, 0}, + {0, 0, Green, 0, 0}, + {0, 0, Green, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {Green, Green, Green, Green, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, Green, 0, 0}, + {0, 0, Green, 0, 0}, + {0, 0, Green, 0, 0}, + {0, 0, Green, 0, 0}, + {0, 0, 0, 0, 0} + } } - } - , + , // L - { - { - {0, 0, 0, 0, 0}, - {0, 0, Red, 0, 0}, - {0, 0, Red, 0, 0}, - {0, 0, Red, Red, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, Red, Red, Red, 0}, - {0, Red, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, Red, Red, 0, 0}, - {0, 0, Red, 0, 0}, - {0, 0, Red, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, Red, 0}, - {0, Red, Red, Red, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - } - }, -// L mirrored - { - { - {0, 0, 0, 0, 0}, - {0, 0, Yellow, 0, 0}, - {0, 0, Yellow, 0, 0}, - {0, Yellow, Yellow, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, Yellow, 0, 0, 0}, - {0, Yellow, Yellow, Yellow, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} + { + { + {0, 0, 0, 0, 0}, + {0, 0, Red, 0, 0}, + {0, 0, Red, 0, 0}, + {0, 0, Red, Red, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, Red, Red, Red, 0}, + {0, Red, 0, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, Red, Red, 0, 0}, + {0, 0, Red, 0, 0}, + {0, 0, Red, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, Red, 0}, + {0, Red, Red, Red, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0} + } }, - { - {0, 0, 0, 0, 0}, - {0, 0, Yellow, Yellow, 0}, - {0, 0, Yellow, 0, 0}, - {0, 0, Yellow, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, Yellow, Yellow, Yellow, 0}, - {0, 0, 0, Yellow, 0}, - {0, 0, 0, 0, 0} - } - }, -// N - { - { - {0, 0, 0, 0, 0}, - {0, 0, 0, Orange, 0}, - {0, 0, Orange, Orange, 0}, - {0, 0, Orange, 0, 0}, - {0, 0, 0, 0, 0} +// L mirrored + { + { + {0, 0, 0, 0, 0}, + {0, 0, Yellow, 0, 0}, + {0, 0, Yellow, 0, 0}, + {0, Yellow, Yellow, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, Yellow, 0, 0, 0}, + {0, Yellow, Yellow, Yellow, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, Yellow, Yellow, 0}, + {0, 0, Yellow, 0, 0}, + {0, 0, Yellow, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, Yellow, Yellow, Yellow, 0}, + {0, 0, 0, Yellow, 0}, + {0, 0, 0, 0, 0} + } }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, Orange, Orange, 0, 0}, - {0, 0, Orange, Orange, 0}, - {0, 0, 0, 0, 0} +// N + { + { + {0, 0, 0, 0, 0}, + {0, 0, 0, Orange, 0}, + {0, 0, Orange, Orange, 0}, + {0, 0, Orange, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, Orange, Orange, 0, 0}, + {0, 0, Orange, Orange, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, Orange, 0, 0}, + {0, Orange, Orange, 0, 0}, + {0, Orange, 0, 0, 0}, + {0, 0, 0, 0, 0} + }, + + + + { + {0, 0, 0, 0, 0}, + {0, Orange, Orange, 0, 0}, + {0, 0, Orange, Orange, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0} + } }, - { - {0, 0, 0, 0, 0}, - {0, 0, Orange, 0, 0}, - {0, Orange, Orange, 0, 0}, - {0, Orange, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - - - - { - {0, 0, 0, 0, 0}, - {0, Orange, Orange, 0, 0}, - {0, 0, Orange, Orange, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - } - }, // N mirrored - { - { - {0, 0, 0, 0, 0}, - {0, 0, GreenYellow, 0, 0}, - {0, 0, GreenYellow, GreenYellow, 0}, - {0, 0, 0, GreenYellow, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, GreenYellow, GreenYellow, 0}, - {0, GreenYellow, GreenYellow, 0, 0}, - {0, 0, 0, 0, 0} + { + { + {0, 0, 0, 0, 0}, + {0, 0, GreenYellow, 0, 0}, + {0, 0, GreenYellow, GreenYellow, 0}, + {0, 0, 0, GreenYellow, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, GreenYellow, GreenYellow, 0}, + {0, GreenYellow, GreenYellow, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, GreenYellow, 0, 0, 0}, + {0, GreenYellow, GreenYellow, 0, 0}, + {0, 0, GreenYellow, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, GreenYellow, GreenYellow, 0}, + {0, GreenYellow, GreenYellow, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0} + } }, - { - {0, 0, 0, 0, 0}, - {0, GreenYellow, 0, 0, 0}, - {0, GreenYellow, GreenYellow, 0, 0}, - {0, 0, GreenYellow, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, GreenYellow, GreenYellow, 0}, - {0, GreenYellow, GreenYellow, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - } - }, // T - { - { - {0, 0, 0, 0, 0}, - {0, 0, Magenta, 0, 0}, - {0, 0, Magenta, Magenta, 0}, - {0, 0, Magenta, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, Magenta, Magenta, Magenta, 0}, - {0, 0, Magenta, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, Magenta, 0, 0}, - {0, Magenta, Magenta, 0, 0}, - {0, 0, Magenta, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - {0, 0, 0, 0, 0}, - {0, 0, Magenta, 0, 0}, - {0, Magenta, Magenta, Magenta, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} + { + { + {0, 0, 0, 0, 0}, + {0, 0, Magenta, 0, 0}, + {0, 0, Magenta, Magenta, 0}, + {0, 0, Magenta, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, Magenta, Magenta, Magenta, 0}, + {0, 0, Magenta, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, Magenta, 0, 0}, + {0, Magenta, Magenta, 0, 0}, + {0, 0, Magenta, 0, 0}, + {0, 0, 0, 0, 0} + }, + { + {0, 0, 0, 0, 0}, + {0, 0, Magenta, 0, 0}, + {0, Magenta, Magenta, Magenta, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0} + } } - } }; \ No newline at end of file
--- a/main.cpp Sat Mar 11 19:50:03 2017 +0000 +++ b/main.cpp Sat Mar 18 14:45:16 2017 +0000 @@ -1,17 +1,23 @@ +/* Tetris game for touchscreen MicroTFT 320x240 and microcontorller LPC1768 + * Uses SeeedStudioTFTv2 library + * Copyright (c) 2017 Sergejs Popovs sergun2311 + */ + #include "mbed.h" #include <ctime> #include "playGround.h" #include "Block.h" #include "Field.h" - -#define SPEED 100 +#include "Define.h" int main() { int score = 0; + int period = SPEED; bool flag; clock_t start_s; TFTInit(); + drawFrame(); drawMap(); while (1) { Block NewBlock; @@ -23,7 +29,7 @@ drawMap(); drawBlock(NewBlock); start_s = clock(); - while( start_s + SPEED > clock() ) { + while( start_s + period > clock() ) { if ( TouchStatus() ) { clrBlock(NewBlock); NewBlock = doGest(NewBlock); @@ -41,9 +47,12 @@ } } score += checkLine(); + if ( score < 3200 ) + period = SPEED - score / 50; clrNextBlock(NewBlock); if ( checkGameOver() ) break; } gameOver(score); + } \ No newline at end of file
--- a/playGround.cpp Sat Mar 11 19:50:03 2017 +0000 +++ b/playGround.cpp Sat Mar 18 14:45:16 2017 +0000 @@ -19,14 +19,11 @@ #define PIN_DC_TFT p21 #define PIN_BL_TFT p15 #define PIN_CS_SD p4 -#define SMALL_BLOCK_SIZE 8 SeeedStudioTFTv2 TFT(PIN_XP, PIN_XM, PIN_YP, PIN_YM, PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TFT, PIN_DC_TFT, PIN_BL_TFT); -void setColor( int y, int x, int color ) -{ - Field[y][x] = color; -} +// Draws Field on the screen. Draw both black and colored blocks +// It does delete everything on the PlayGround what shouldn't be there void drawMap() { @@ -45,15 +42,18 @@ } } +// Draws Field on the screen. Draw only colored blocks +// It doesn't delete anything on the playground what shouldn't be there + void drawMapV2() { int y , x; for ( y = 0 ; y < MAXY ; y++ ) { for ( x = 0 ; x < MAXX ; x++ ) { TFT.fillrect(20 * ( x + 1 ), 20 * y, - BLOCK_SIZE * ( x + 2 ), BLOCK_SIZE * ( y + 1 ), - Field[y][x]); - if ( Field[y][x] != 0 ) + BLOCK_SIZE * ( x + 2 ), BLOCK_SIZE * ( y + 1 ), + Field[y][x]); + if ( Field[y][x] != 0 ) TFT.rect(BLOCK_SIZE * ( x + 1 ), BLOCK_SIZE * y, BLOCK_SIZE * ( x + 2 ), BLOCK_SIZE * ( y + 1 ), 0xFFFF ); @@ -61,6 +61,8 @@ } } +// Draws NewBlock on the playground. + void drawBlock(Block NewBlock) { int ix , iy , x , y; @@ -79,6 +81,8 @@ } } +// Removes NewBlock from the playground. + void clrBlock(Block NewBlock) { int ix , iy , x , y; @@ -94,6 +98,8 @@ } } +// Draws purple frame around playground + void drawFrame() { int x, y; @@ -110,6 +116,9 @@ } } +// Initializes screen parameters, sets orentation, background, +// fonts and cleans screen. + void TFTInit() { TFT.set_orientation(0); @@ -117,9 +126,15 @@ TFT.background(0); TFT.cls(); TFT.set_font((unsigned char*) Arial24x23); - drawFrame(); } +// Reads gestures from the screen. +// Returns : 0 for dropping object down +// 1 for moving object to the right +// 2 for moving object to the left +// 3 for rotating object counter-clockwise +// 4 for rotating objec clockwise + int getGesture() { point p; @@ -154,6 +169,8 @@ return 13; //13 = IGNORE } +// Returns status of screen. If it was touched returns true, else false + bool TouchStatus() { point p; @@ -162,11 +179,12 @@ return false; } +// Moves NewBlock acording the gesture was read by function getGesture. + Block doGest(Block NewBlock) { int gest = getGesture(); if ( gest != 13 ) { - //clrBlock(NewBlock); switch ( gest ) { case 0: { while ( !NewBlock.CheckBottom() ) { @@ -197,6 +215,8 @@ return NewBlock; } +// Clearing the screen and displays "Game Over" title and final score + void gameOver(int score) { TFT.cls(); @@ -204,15 +224,20 @@ TFT.printf("Score : %i", score); } +// Draws the current score on the bottom of the screen + void drawScore(int score) { TFT.set_font((unsigned char*) Arial12x12); TFT.locate(0,300); TFT.printf("Score : %i", score); TFT.set_font((unsigned char*) Arial24x23); - + } +// Draws the next block on the bottom of the screen. +// Block is sized of SMALL_BLOCK_SIZED + void drawNextBlock(Block NewBlock) { int ix , iy , x , y; @@ -231,7 +256,9 @@ } } +// Clearing NextBlock Simbol on the bottom of the screen + void clrNextBlock(Block NewBlock) { TFT.fillrect( 180 , 263 , 240, 320 , 0 ); -} \ No newline at end of file +}
--- a/playGround.h Sat Mar 11 19:50:03 2017 +0000 +++ b/playGround.h Sat Mar 18 14:45:16 2017 +0000 @@ -1,10 +1,10 @@ #include "mbed.h" #include "SeeedStudioTFTv2.h" #include "Block.h" +#include "Define.h" void drawMap(); void drawMapV2(); -void setColor( int y, int x, int color ); void TFTInit(); void drawBlock(Block NewBlock); void drawFrame();