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
Game.h@0:3b5e97ab5884, 2014-10-21 (annotated)
- Committer:
- sucrelv
- Date:
- Tue Oct 21 15:10:36 2014 +0000
- Revision:
- 0:3b5e97ab5884
initial upload
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sucrelv | 0:3b5e97ab5884 | 1 | #ifndef _GAME_ |
sucrelv | 0:3b5e97ab5884 | 2 | #define _GAME_ |
sucrelv | 0:3b5e97ab5884 | 3 | |
sucrelv | 0:3b5e97ab5884 | 4 | // ------ Includes ----- |
sucrelv | 0:3b5e97ab5884 | 5 | |
sucrelv | 0:3b5e97ab5884 | 6 | #include "Board.h" |
sucrelv | 0:3b5e97ab5884 | 7 | #include "Pieces.h" |
sucrelv | 0:3b5e97ab5884 | 8 | #include "uLCD_4DGL.h" |
sucrelv | 0:3b5e97ab5884 | 9 | |
sucrelv | 0:3b5e97ab5884 | 10 | // ------ Defines ----- |
sucrelv | 0:3b5e97ab5884 | 11 | |
sucrelv | 0:3b5e97ab5884 | 12 | #define WAIT_TIME 500 // Number of milliseconds that the piece remains before going 1 block down */ |
sucrelv | 0:3b5e97ab5884 | 13 | |
sucrelv | 0:3b5e97ab5884 | 14 | |
sucrelv | 0:3b5e97ab5884 | 15 | // -------------------------------------------------------------------------------- |
sucrelv | 0:3b5e97ab5884 | 16 | // Game |
sucrelv | 0:3b5e97ab5884 | 17 | // -------------------------------------------------------------------------------- |
sucrelv | 0:3b5e97ab5884 | 18 | |
sucrelv | 0:3b5e97ab5884 | 19 | class Game |
sucrelv | 0:3b5e97ab5884 | 20 | { |
sucrelv | 0:3b5e97ab5884 | 21 | public: |
sucrelv | 0:3b5e97ab5884 | 22 | |
sucrelv | 0:3b5e97ab5884 | 23 | Game (Board *pBoard, Pieces *pPieces, int pScreenHeight, uLCD_4DGL *uLCD,int,int,int,int); |
sucrelv | 0:3b5e97ab5884 | 24 | |
sucrelv | 0:3b5e97ab5884 | 25 | void DrawScene (); |
sucrelv | 0:3b5e97ab5884 | 26 | void CreateNewPiece (int,int); |
sucrelv | 0:3b5e97ab5884 | 27 | void ErasePiece(int x,int y,int piece, int rotation); |
sucrelv | 0:3b5e97ab5884 | 28 | void DrawBoard (); |
sucrelv | 0:3b5e97ab5884 | 29 | void AddPoints(int); |
sucrelv | 0:3b5e97ab5884 | 30 | void AddClearedLines(int); |
sucrelv | 0:3b5e97ab5884 | 31 | int GetPoints(); |
sucrelv | 0:3b5e97ab5884 | 32 | int GetClearedLines(); |
sucrelv | 0:3b5e97ab5884 | 33 | |
sucrelv | 0:3b5e97ab5884 | 34 | int mPosX, mPosY; // Position of the piece that is falling down |
sucrelv | 0:3b5e97ab5884 | 35 | int mPiece, mRotation; // Kind and rotation the piece that is falling down |
sucrelv | 0:3b5e97ab5884 | 36 | int points; |
sucrelv | 0:3b5e97ab5884 | 37 | int clearedLineCount; |
sucrelv | 0:3b5e97ab5884 | 38 | |
sucrelv | 0:3b5e97ab5884 | 39 | |
sucrelv | 0:3b5e97ab5884 | 40 | private: |
sucrelv | 0:3b5e97ab5884 | 41 | |
sucrelv | 0:3b5e97ab5884 | 42 | int mScreenHeight; // Screen height in pixels |
sucrelv | 0:3b5e97ab5884 | 43 | int mNextPosX, mNextPosY; // Position of the next piece |
sucrelv | 0:3b5e97ab5884 | 44 | int mNextPiece, mNextRotation; // Kind and rotation of the next piece |
sucrelv | 0:3b5e97ab5884 | 45 | |
sucrelv | 0:3b5e97ab5884 | 46 | Board *mBoard; |
sucrelv | 0:3b5e97ab5884 | 47 | Pieces *mPieces; |
sucrelv | 0:3b5e97ab5884 | 48 | uLCD_4DGL *uLCD; |
sucrelv | 0:3b5e97ab5884 | 49 | |
sucrelv | 0:3b5e97ab5884 | 50 | |
sucrelv | 0:3b5e97ab5884 | 51 | void InitGame(int,int,int,int); |
sucrelv | 0:3b5e97ab5884 | 52 | void DrawPiece (int pX, int pY, int pPiece, int pRotation, int colorIndex); |
sucrelv | 0:3b5e97ab5884 | 53 | |
sucrelv | 0:3b5e97ab5884 | 54 | }; |
sucrelv | 0:3b5e97ab5884 | 55 | |
sucrelv | 0:3b5e97ab5884 | 56 | #endif // _GAME_ |