-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathBlock.cpp
66 lines (59 loc) · 1.4 KB
/
Block.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
// Block.cpp: implementation of the CBlock class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "¶íÂÞ˹·½¿é.h"
#include "Block.h"
#include "Diamond.h"
#include "Panel.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern CDiamond* pDiamond;
extern CMyApp theApp;
extern CPanel* pPanel;
CBlock::CBlock()
{
for(int iy=0;iy<80;iy++)
for(int ix=0;ix<30;ix++)
BlockPanel[ix][iy]=false;
}
CBlock::~CBlock()
{
}
void CBlock::AddBlock()
{
for(int iy=0;iy<4;iy++)
for(int ix=0;ix<4;ix++)
{
if(pDiamond->DiamondStruct[pDiamond->DiamondType][pDiamond->DiamondState][ix][iy])
BlockPanel[pDiamond->DiamondPos.x+ix][pDiamond->DiamondPos.y+iy]=true;
}
}
void CBlock::DrawBlock(CDC *pDC)
{
CBrush brush;
brush.CreateSolidBrush(BlockColor);
CBrush *pOld=pDC->SelectObject(&brush);
for(int iy=0;iy<=pPanel->nVGridNum;iy++)
{
for(int ix=0;ix<=pPanel->nHGridNum;ix++)
{
if(BlockPanel[ix][iy]==true)
{
POINT point;
point.x=ix;
point.y=iy;
pPanel->PanelPosToPos(point);
pDC->Rectangle(point.x,point.y,point.x+pPanel->GridSize.cx,point.y+pPanel->GridSize.cy);
}
}
}
pDC->SelectObject(pOld);
brush.DeleteObject();
}