-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.h
93 lines (63 loc) · 1.74 KB
/
Game.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* The main Game class.
* Game specific Stuff is handled here but the input reading
* and drawing and the Gameloop is handled by the parent "Screen"
* class. But we have to fill the screen buffer here,
* so the parent class know what to draw.
**/
#ifndef GAME_H
#define GAME_H
#include <iostream>
#include <chrono>
#include <vector>
#include <algorithm>
#include "Screen.h"
#include "WorldConstants.h"
#include "PointF.h"
#include "Stone.h"
#include "FallenStone.h"
#include "ScreenBuffer.h"
typedef std::chrono::high_resolution_clock CLOCK;
class Game : public Screen
{
private:
bool m_paused;
// The time since the last regular update
CLOCK::time_point m_timeStart;
// The current standard step time in miliseconds
int m_standardStepTime;
int m_currentStepTime;
// The player can manually increase the Step Time so the stone falls faster
const int m_stepTimeFast;
// The actual Stone which are under the players controll
Stone m_currentStone;
// The next Stone
Stone m_nextStone;
std::vector<FallenStone> m_fallenStones;
// The removed lines since the the player is in the current level
unsigned int m_removedLinesLevel;
unsigned int m_removedLinesTotal;
unsigned int m_level;
unsigned int m_score;
public:
Game(ScreenBuffer *screenBuffer);
private:
bool isCurrentStoneColliding() const;
bool isStepTimeLeft() const;
void cleanFullRow(const int row);
void removeFullRows();
void leaveGame();
bool isGameOver();
void spawnStone();
void updateTimeAffected();
virtual void handleInput();
virtual void update();
void drawStats();
void drawNextStone();
void drawGameField();
void drawFallenStones();
void drawControlInfo();
void drawPauseInfo();
virtual void fillScreenBuffer();
};
#endif // !GAME_H