This is a remake of tetris game for mbed. Please see detail here http://developer.mbed.org/users/sucrelv/notebook/tetris-game-on-mbed

Dependencies:   4DGL-uLCD-SE PinDetect SDFileSystem mbed-rtos mbed wave_player

Committer:
sucrelv
Date:
Tue Oct 21 15:10:36 2014 +0000
Revision:
0:3b5e97ab5884
initial upload

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sucrelv 0:3b5e97ab5884 1 #ifndef _BOARD_
sucrelv 0:3b5e97ab5884 2 #define _BOARD_
sucrelv 0:3b5e97ab5884 3
sucrelv 0:3b5e97ab5884 4 // ------ Includes -----
sucrelv 0:3b5e97ab5884 5
sucrelv 0:3b5e97ab5884 6 #include "Pieces.h"
sucrelv 0:3b5e97ab5884 7
sucrelv 0:3b5e97ab5884 8 // ------ Defines -----
sucrelv 0:3b5e97ab5884 9
sucrelv 0:3b5e97ab5884 10 #define BOARD_LINE_WIDTH 6 // Width of each of the two lines that delimit the board
sucrelv 0:3b5e97ab5884 11 #define BLOCK_SIZE 6 // Width and Height of each block of a piece
sucrelv 0:3b5e97ab5884 12 #define BOARD_POSITION 50 // Center position of the board from the left of the screen
sucrelv 0:3b5e97ab5884 13 #define BOARD_WIDTH 10 // Board width in blocks
sucrelv 0:3b5e97ab5884 14 #define BOARD_HEIGHT 20 // Board height in blocks
sucrelv 0:3b5e97ab5884 15 #define MIN_VERTICAL_MARGIN 8 // Minimum vertical margin for the board limit
sucrelv 0:3b5e97ab5884 16 #define MIN_HORIZONTAL_MARGIN 20 // Minimum horizontal margin for the board limit
sucrelv 0:3b5e97ab5884 17 #define PIECE_BLOCKS 5 // Number of horizontal and vertical blocks of a matrix piece
sucrelv 0:3b5e97ab5884 18
sucrelv 0:3b5e97ab5884 19
sucrelv 0:3b5e97ab5884 20 // --------------------------------------------------------------------------------
sucrelv 0:3b5e97ab5884 21 // Board
sucrelv 0:3b5e97ab5884 22 // --------------------------------------------------------------------------------
sucrelv 0:3b5e97ab5884 23
sucrelv 0:3b5e97ab5884 24 class Board
sucrelv 0:3b5e97ab5884 25 {
sucrelv 0:3b5e97ab5884 26 public:
sucrelv 0:3b5e97ab5884 27
sucrelv 0:3b5e97ab5884 28 Board (Pieces *pPieces, int pScreenHeight);
sucrelv 0:3b5e97ab5884 29
sucrelv 0:3b5e97ab5884 30 int GetXPosInPixels (int pPos);
sucrelv 0:3b5e97ab5884 31 int GetYPosInPixels (int pPos);
sucrelv 0:3b5e97ab5884 32 bool IsFreeBlock (int pX, int pY);
sucrelv 0:3b5e97ab5884 33 bool IsPossibleMovement (int pX, int pY, int pPiece, int pRotation);
sucrelv 0:3b5e97ab5884 34 void StorePiece (int pX, int pY, int pPiece, int pRotation);
sucrelv 0:3b5e97ab5884 35 int DeletePossibleLines ();
sucrelv 0:3b5e97ab5884 36 bool IsGameOver ();
sucrelv 0:3b5e97ab5884 37
sucrelv 0:3b5e97ab5884 38 private:
sucrelv 0:3b5e97ab5884 39
sucrelv 0:3b5e97ab5884 40 enum { POS_FREE, POS_FILLED }; // POS_FREE = free position of the board; POS_FILLED = filled position of the board
sucrelv 0:3b5e97ab5884 41 int mBoard [BOARD_WIDTH][BOARD_HEIGHT]; // Board that contains the pieces
sucrelv 0:3b5e97ab5884 42 Pieces *mPieces;
sucrelv 0:3b5e97ab5884 43 int mScreenHeight;
sucrelv 0:3b5e97ab5884 44
sucrelv 0:3b5e97ab5884 45 void InitBoard();
sucrelv 0:3b5e97ab5884 46 void DeleteLine (int pY);
sucrelv 0:3b5e97ab5884 47 };
sucrelv 0:3b5e97ab5884 48
sucrelv 0:3b5e97ab5884 49 #endif