-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameBoard.h
More file actions
75 lines (52 loc) · 1.36 KB
/
Copy pathGameBoard.h
File metadata and controls
75 lines (52 loc) · 1.36 KB
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
#pragma once
#include <vector>
#include <map>
#include "Element.h"
class GameBoard
{
public:
GameBoard() : rows(20), cols(20) {}
GameBoard(int rows, int columns);
void holdElement();
void undHoldElement();
void spawn(Element& element);
void despawn();
void moveElement(Element& element, int col, int row);
void rotateElement(Element::Rotation rotation);
bool checkForCollisions(Element& element);
bool checkForCollisions(std::map<int, std::vector<int>> shape, int x_, int y_);
int dropElement(Element& element);
void moveRowsDown();
void clearRowLines(int row);
void clearColumnLines(int cols);
void clearBoard();
std::vector<int> fullRows();
bool isTopRowOccupied();
bool isRowOccupied(int row);
int getLowestPosition(Element element);
void settleElement(Element& element);
int getX()
{
return x;
}
int getY()
{
return y;
}
void setY(int value)
{
y = value;
}
std::map<int, std::vector<Element::Color>> getElements() const
{
return elements;
}
private:
bool spawned;
int rows, cols;
int x, y;
std::map<int, std::vector<Element::Color>> elements;
bool canBeMoved;
bool isPositionPossible(int row, int col, const Element& element) const;
std::vector<int> findLinesToClear();
};