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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Board.h Source File

Board.h

00001 #ifndef _BOARD_
00002 #define _BOARD_
00003 
00004 // ------ Includes -----
00005 
00006 #include "Pieces.h"
00007 
00008 // ------ Defines -----
00009 
00010 #define BOARD_LINE_WIDTH 6          // Width of each of the two lines that delimit the board
00011 #define BLOCK_SIZE 6              // Width and Height of each block of a piece
00012 #define BOARD_POSITION 50          // Center position of the board from the left of the screen
00013 #define BOARD_WIDTH 10              // Board width in blocks 
00014 #define BOARD_HEIGHT 20             // Board height in blocks
00015 #define MIN_VERTICAL_MARGIN 8      // Minimum vertical margin for the board limit      
00016 #define MIN_HORIZONTAL_MARGIN 20    // Minimum horizontal margin for the board limit
00017 #define PIECE_BLOCKS 5              // Number of horizontal and vertical blocks of a matrix piece
00018 
00019 
00020 // --------------------------------------------------------------------------------
00021 //                                   Board
00022 // --------------------------------------------------------------------------------
00023 
00024 class Board
00025 {
00026 public:
00027 
00028     Board                       (Pieces *pPieces, int pScreenHeight);
00029 
00030     int GetXPosInPixels         (int pPos);
00031     int GetYPosInPixels         (int pPos);
00032     bool IsFreeBlock            (int pX, int pY);
00033     bool IsPossibleMovement     (int pX, int pY, int pPiece, int pRotation);
00034     void StorePiece             (int pX, int pY, int pPiece, int pRotation);
00035     int DeletePossibleLines    ();
00036     bool IsGameOver             ();
00037 
00038 private:
00039 
00040     enum { POS_FREE, POS_FILLED };          // POS_FREE = free position of the board; POS_FILLED = filled position of the board
00041     int mBoard [BOARD_WIDTH][BOARD_HEIGHT]; // Board that contains the pieces
00042     Pieces *mPieces;
00043     int mScreenHeight;
00044 
00045     void InitBoard();
00046     void DeleteLine (int pY);
00047 };
00048 
00049 #endif