-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.h
76 lines (58 loc) · 1.43 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
#pragma once
#include "grid.h"
#include "block-subclass.cpp"
#include "cmath"
class Game
{
public:
Game();
void Update();
void Draw();
void HandleInput();
Grid grid{};
private:
void DrawHoldBlock(const Block& block);
void DrawNextBlock(const Block& block);
// Game Controls Methods
void HandleDelayedInput(int key, void (Game::* actionFunction)());
void MoveBlock(int rowChange, int colChange);
void MoveBlockRight();
void MoveBlockLeft();
void MoveBlockDown();
void RotateBlockClockwise();
void RotateBlockCounterClockwise();
void Rotate180();
void HoldBlock();
void HardDropBlock();
void SoftDropBlock();
void LockBlock();
void DropBlock();
// Block Queue Methods
void RandomizeBag();
Block GetRandomBlock();
// Ghost Block Methods
void DrawGhostBlock(const Block& block);
int TileDropDistance(const Position& block);
int BlockDropDistance();
// Gravity Methods
void BlockGravity();
bool EventTriggered(double interval);
// Collision Methods
bool DoesBlockFit();
void CheckCollisions(int initRot, int finalRot);
Position ComputeResultantCoordinate(Position initial, Position final);
Position GetMoveCoordinate(int initRotate, int finalRotate);
// Reset Game
void Reset();
// Variables
Block currentBlock{};
Block heldBlock{};
std::vector<Block> blockBag{};
bool isHoldEmpty{};
bool isHoldUsed{};
float arrTime{};
float arrDelay{};
float dasTime{};
float dasDelay{};
double lastUpdateTime{};
};