-
Notifications
You must be signed in to change notification settings - Fork 0
/
TetrisBase.h
59 lines (54 loc) · 1.2 KB
/
TetrisBase.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
#ifndef TETRIS_BASE_H
#define TETRIS_BASE_H
#include "Point.h"
#include "Product.h"
#include "AggregateBase.h"
class TetrisBase : public Point,public Product
{
public:
friend ostream& operator<<(ostream& os, const TetrisBase& tetris);
TetrisBase(PDCTYPE type);
virtual ~TetrisBase();
virtual void use(){};
//进行旋转
virtual void rotate(int angle);
virtual Vel2 getPosition()
{
return Point::getPosition();
}
virtual int GetAngle()
{
return m_angle;
}
//将自己的坐标填写到指定map上面;
virtual bool PinToMap(AggregateBase* map);
virtual void moveLeft()
{
Vel2 direction_left;
direction_left(0,-1);
Vel2 offset = direction_left*_v.speed;
setPosition(_position + offset);
}
virtual void moveRight()
{
Vel2 direction_right;
direction_right(0, 1);
Vel2 offset = direction_right*_v.speed;
setPosition(_position + offset);
}
virtual void moveUp()
{
Vel2 direction_up;
direction_up(-1, 0);
Vel2 offset = direction_up*_v.speed;
setPosition(_position + offset);
}
virtual int GetTetrisOffset() = 0; //真正的图形的相对偏移,用于校正
private:
int m_ID;
int m_angle;
void rotate90();
protected:
AggregateBase *m_map;
};
#endif