-
Notifications
You must be signed in to change notification settings - Fork 0
/
方块类
48 lines (43 loc) · 1.03 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
class block
{
public:
int x,y;//方块位置
int b[4][4];//方块形状
void getp(int X,int Y,int b1[4][4])//方块初始化
{
x=X;y=Y;
memcpy(b,b1,64);
}
void setcolor(int b[4][4])//设置方块颜色
{
switch(b[0][0])
{
case 10:case 11: SCT(hOut,FGRE); break;
case 12:case 13:case 14:case 15:SCT(hOut,FBLU|FGRE|FINT); break;
case 16:case 17:case 18:case 19:SCT(hOut,FRED|FGRE|FINT); break;
case 20:case 21: SCT(hOut,FGRE|FINT); break;
case 22:case 23: SCT(hOut,FBLU|FINT); break;
case 24:case 25:case 26:case 27:SCT(hOut,FRED|FBLU|FINT); break;
case 28: SCT(hOut,FRED|FINT); break;
default:
break;
}
}
void print()//打印方块
{
setcolor(b);
for(i=0;i<4;i++)
{
if(i+x<0) continue;
for(j=0;j<4;j++) if(b[i][j]==1) gotoXY(2*(y+j),x+i,"■");
}
}
void clear()//消除方块
{
for(i=0;i<4;i++)
{
if(i+x<0) continue;
for(j=0;j<4;j++) if(b[i][j]==1) gotoXY(2*(y+j),x+i," ");
}
}
};