-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathMill.cpp
108 lines (100 loc) · 2.13 KB
/
Mill.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Mill.cpp: implementation of the CMill class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "¶íÂÞ˹·½¿é.h"
#include "Mill.h"
#include "Diamond.h"
#include "Manager.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern CMyApp theApp;
extern CDiamond* pDiamond;
CMill::CMill()
{
//Éú³É
PreDiamondType=rand()%7;
PreDiamondState=rand()%4;
}
CMill::~CMill()
{
}
void CMill::MadeDiamond()
{
pDiamond->DiamondType=PreDiamondType;
pDiamond->DiamondState=PreDiamondState;
pDiamond->DiamondPos.x=5;
pDiamond->DiamondPos.y=0;
//Éú³É
int nMax;
int Cake=rand()*probabilityCake/100;
PreDiamondType=DIAMONDCAKE;
nMax=Cake;
int Hook=rand()*probabilityHook/100;
if(Hook>nMax)
{
nMax=Hook;
PreDiamondType=DIAMONDHOOK;
}
int Seven=rand()*probabilitySeven/100;
if(Seven>nMax)
{
nMax=Seven;
PreDiamondType=DIAMONDSEVEN;
}
int Heave=rand()*probabilityHeave/100;
if(Heave>nMax)
{
nMax=Heave;
PreDiamondType=DIAMONDHEAVE;
}
int Bar=rand()*probabilityBar/100;
if(Bar>nMax)
{
nMax=Bar;
PreDiamondType=DIAMONDBAR;
}
int Two=rand()*probabilityTwo/100;
if(Two>nMax)
{
nMax=Two;
PreDiamondType=DIAMONDTWO;
}
int Spade=rand()*probabilitySpade/100;
if(Spade>nMax)
{
nMax=Spade;
PreDiamondType=DIAMONDSPADE;
}
PreDiamondState=rand()%4;
}
void CMill::DrawPrepare(CDC* pDC)
{
CBrush brush,GridBrush;
brush.CreateSolidBrush(MillColor);
CBrush *pOld=pDC->SelectObject(&brush);
//
pDC->Rectangle(&MillRect);
//
GridBrush.CreateSolidBrush(PreColor);
pDC->SelectObject(&GridBrush);
for(int iy=0;iy<4;iy++)
{
for(int ix=0;ix<4;ix++)
{
if(pDiamond->DiamondStruct[PreDiamondType][PreDiamondState][ix][iy])
{
pDC->Rectangle(MillRect.left+ix*GridSize.cx,MillRect.top+iy*GridSize.cy,MillRect.left+(ix+1)*GridSize.cx,MillRect.top+(iy+1)*GridSize.cy);
}
}
}
pDC->SelectObject(pOld);
GridBrush.DeleteObject();
brush.DeleteObject();
}