-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlock.cpp
More file actions
104 lines (93 loc) · 1.93 KB
/
Copy pathBlock.cpp
File metadata and controls
104 lines (93 loc) · 1.93 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include<vector>
#include "coordinate.h"
#include "Block.h"
using namespace std;
void Block::right()
{
//shift every element to the right by one
for(int i = 0; i < blockParts_.size(); i++)
{
blockParts_[i]->shiftCol(1);
}
}
void Block::left()
{
//shift every element to the left by one
for(int i = 0; i < blockParts_.size(); i++)
{
blockParts_[i]->shiftCol(-1);
}
}
void Block::down()
{
//shift every element down by one
for(int i = 0; i < blockParts_.size(); i++)
{
blockParts_[i]->shiftRow(1);
}
}
void Block::up()
{
//shift every element up by one
for(int i = 0; i < blockParts_.size(); i++)
{
blockParts_[i]->shiftRow(-1);
}
}
vector<shared_ptr<coordinate>> Block::getCoordinates()
{
return blockParts_;
}
int Block::getLevelGenerated()
{
return levelGenerated_;
}
//Delete coordinate if coordinate's row equals the inputted row
//If the coordinate's row is above the inputted row, move the row down by one
void Block::deleteRow(int row)
{
for(int i = 0; i < blockParts_.size(); i++)//Delete block parts inside the row
{
if(blockParts_[i]->row_ == row)
{
blockParts_.erase(blockParts_.begin() + i);
i--;
}
}
for(int i = 0; i < blockParts_.size(); i++)//Increment rows if necessary
{
if(blockParts_[i]->row_ < row)
{
blockParts_[i]->shiftRow(1);
}
}
}
void Block::changeStateTwo()
{
rotationState_++;
if(rotationState_ > 2)
{
rotationState_ = 1;
}
}
void Block::changeStateFour(bool forward)
{
if(forward)
{
rotationState_++;
if(rotationState_ > 4)
{
rotationState_ = 1;
}
}
else
{
rotationState_--;
if(rotationState_ < 1)
{
rotationState_ = 4;
}
}
}
BlockFactory::BlockFactory() {}
BlockFactory::~BlockFactory() {}