-
Notifications
You must be signed in to change notification settings - Fork 0
/
XBlock.cpp
40 lines (33 loc) · 1.19 KB
/
XBlock.cpp
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
#include <vector>
#include "XBlock.h"
#include "coordinate.h"
using namespace std;
XBlock::XBlock(int levelNum)
{
// Set the block's position to its initial position as shown below
// Vertical numbers: row number, Horizontal numbers: column number
// 1 2 3
// 1
// 2
// 3
// 4 X X
// 5 X
// 6 X X
blockParts_.push_back(shared_ptr<coordinate>(new coordinate(4, 1)));//block part 1, denoted as c1
blockParts_.push_back(shared_ptr<coordinate>(new coordinate(4, 3)));//block part 2, denoted as c2
blockParts_.push_back(shared_ptr<coordinate>(new coordinate(5, 2)));//block part 3, denoted as c3
blockParts_.push_back(shared_ptr<coordinate>(new coordinate(6, 1)));//block part 4, denoted as c4
blockParts_.push_back(shared_ptr<coordinate>(new coordinate(6, 3)));//block part 5, denoted as c5
levelGenerated_ = levelNum;
}
char XBlock::getType() const{
return 'X';
}
XBlock::~XBlock() {}
//This block's rotational symmetry makes the rotate function trivial
void XBlock::rotate(bool clockwise) {}
XBlockFactory::XBlockFactory() {}
shared_ptr<Block> XBlockFactory::createBlock(int levelNum)
{
return shared_ptr<XBlock>(new XBlock(levelNum));
}