-
Notifications
You must be signed in to change notification settings - Fork 0
/
Block.h
47 lines (40 loc) · 1.18 KB
/
Block.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
#ifndef _BLOCK_H_
#define _BLOCK_H_
#include <vector>
#include <memory>
#include "coordinate.h"
class Block;
class AbstractBlockFactory;
//The base factory all other the factories will inherit.
class BlockFactory
{
friend class AbstractBlockFactory;
public:
virtual ~BlockFactory();
virtual std::shared_ptr<Block> createBlock(int levelNum) = 0;
protected:
BlockFactory();
};
class Block
{
friend class BlockFactory;
public:
virtual ~Block() {}
virtual void rotate(bool clockwise) = 0;
void deleteRow(int row);
void right();//move right by one
void left();//move left by one
void down();//move down by one
void up();//move up by one
std::vector<std::shared_ptr<coordinate>> getCoordinates();
int getLevelGenerated();
virtual char getType() const = 0;
protected:
Block() {};
int levelGenerated_;
int rotationState_;
std::vector<std::shared_ptr<coordinate>> blockParts_;
void changeStateTwo();//change rotation states for blocks with 2 states
void changeStateFour(bool forward);//change rotation states for blocks with 4 states
};
#endif