-
Notifications
You must be signed in to change notification settings - Fork 0
/
CSquare.cpp
87 lines (78 loc) · 1.97 KB
/
CSquare.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
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
#include "typedef.h"
/*
class CBrick {
const static unsigned char brickType[SHAPE_NUM];
protected:
static CBoard &board;
short x,y;
unsigned char color, direction;
virtual void erase()=0;
virtual void show()=0;
virtual bool isProped()=0;
public:
CBrick(short x_, short y_, char color_, unsigned char direction_);
virtual ~CBrick();
static CBrick* newBrick();
int mvDown(int command=UNDEFINED);
virtual int mvLeft()=0;
virtual int mvRight()=0;
virtual int rotateLeft();
virtual int rotateRight();
friend class CDisplay;
};
class CSquare:public CBrick{
virtual void erase();
virtual void show();
virtual bool isProped();
public:
CSquare(short x_, short y_, char color_, unsigned char direction_);
virtual int mvLeft();
virtual int mvRight();
};
*/
CSquare::CSquare(short x_, short y_, char color_, unsigned char direction_):CBrick(x_,y_,color_,direction_){
if ( x_<1 || x_>11 ) x = 6;
if ( y_>30 || y_<1 ) y = 30;
switch ( direction_ ) {
case SQUARE:
break;
default:
x=0;
y=0;
color = 0;
direction = 0;
break;
}
return;
}
void CSquare::show(){
board<<CTriangle(x, y, color, LUTRIANGLE)<<CTriangle(x, y, color, RDTRIANGLE);
return;
}
void CSquare::erase(){
board>>CTriangle(x, y, 0, LUTRIANGLE)>>CTriangle(x, y, 0, RDTRIANGLE);
return;
}
bool CSquare::isProped(){
bool result;
result = board.getRim(x,y-1);
return result;
}
int CSquare::mvLeft(){
bool stopped;
stopped = board.getRim(x-1,y);
if ( stopped ) return mvDown();
erase();
x--;
show();
return MV_LEFT;
}
int CSquare::mvRight(){
bool stopped;
stopped = board.getRim(x+1,y);
if ( stopped ) return mvDown();
erase();
x++;
show();
return MV_RIGHT;
}