-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayChess.cpp
68 lines (63 loc) · 1.19 KB
/
playChess.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
#include"playChess.h"
void playGame(int board[20][20], bool flag)
{
MOUSEMSG m;
int x = 0, y = 0;//实际坐标
int line = 0, col = 0;//行数,列数坐标
while (1)
{
m = GetMouseMsg();
for (int i = 1; i < 20; i++)
{
for (int j = 1; j < 20; j++)
{
if (abs(m.x - i * 25) < 10 && abs(m.y - j * 25) < 10)
{
//如果是这种情况下,就判定 是这个坐标了
x = i * 25;
y = j * 25;
line = i;
col = j;
}
}
}
if (m.uMsg == WM_LBUTTONDOWN)
{
if (board[line][col] != 0)
{
MessageBox(NULL,"已经由棋子了","提示",MB_OK);
continue;
}
if (!flag)//碰上黑子了
{
setfillcolor(BLACK);
solidcircle(x, y, 10);//绝对像素
board[line][col] = 1;//黑子是1
flag = true;
}
else
{
setfillcolor(WHITE);
solidcircle(x, y, 10);
board[line][col] = 2;//白子是2
flag = false;
}
}
int temp;
if (temp = judge(line, col, flag, board))
{
if (flag)
{
MessageBox(NULL, "黑子胜利", "游戏结束", MB_OK);
exit(0);
}
else
{
MessageBox(NULL, "白子胜利", "游戏结束", MB_OK);
exit(0);
}
}
//printf("%d\n", temp);
//flag = !flag;
}
}