-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTetrisGame.h
61 lines (38 loc) · 1.62 KB
/
TetrisGame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _Tetris_Game
#define _Tetris_Game
#include "ScoreBar.h"
#include <iostream>
using namespace std;
#define ROW 15
#define COLUMN 10
class TetrisGame
{
enum { invalid_Key = -1, ESC = 27, SPACE_key = 32, s_key = 115, S_key = 83, ONE = 49, TWO = 50, THREE = 51, FOUR = 52, DOWN_KEY = 80, LEFT_KEY = 75, UP_KEY = 72, RIGHT_KEY = 77 };
enum { PAUSED = 78, PLAYING, END_GAME, CONTINUE_GAME = 0 };
Shape* currentShape;
char keyboards[11];
int Board[COLUMN][ROW], gameStarted = 0;
public:
void setGameStarted();
void displayBorder() const;
int runGame(TetrisBoard& board, Score& scoreStatus);
// The function initializing the game
void initGame();
// The function is getting a key and cheaks if its valid key
int checkKeys(char ch) const;
void setKeys();
int randomNum() const;
int dropInterval(TetrisBoard& board, Score& scoreStatus, int& timeInterval, int&minY, int& maxY);
void printMenu();
void printGameOver() const;
bool checkExit(char keyEntered) const;
bool checkPause(char keyEntered) const;
void newRound(int& timeInterval, TetrisBoard& board, int& minY, int& maxY, Score& scoreStatus, int& whichShape);
void changeSpeed(char indicator, int& timeInterval, Score& scoreStatus);
int MenuControl(char keyPressed, TetrisBoard& board, Score& scoreStatus);
void continueBlink();
void updateInterval(int& timeInterval, Score& scoreStatus) { timeInterval = 800 - 300 * scoreStatus.getSpeed();}
void hardDrop(Score& scoreStatus, int& timeInterval, unsigned long int& currentTime, int& minY, int& maxY);
void createNewShape(int whichShape);
};
#endif