#include <stdio.h>
#include "graphics.h"
#include "misc.h"
extern BOOLEAN gbIsPlaying;
int main(int argc, char* argv[])
{
GmInitialize();
UCHAR szOutText0[] = "Game over! You are winner!";
UCHAR szOutText1[] = "Game over! You are loser!";
UCHAR szOutText2[] = "Press 'Y' to restart or 'N' to quit.";
//key_msg keyMsg;
MOUSEMSG tMsg;
GAME_STATUS bStatus;
while (1) {
tMsg = GetMouseMsg();
if (gbIsPlaying) {
if (tMsg.uMsg == WM_LBUTTONDOWN) {
POS tPos;
if ( GmGetIndexByMouseMsg(tMsg, &tPos) ) {
bStatus = GmHumanTurn(tPos);
if (bStatus != STATUS_PLAYING) {
setfont(CELL_HEIGHT / 2, CELL_WIDTH / 3, "黑体");
if (bStatus == STATUS_HUMAN_WIN) {
setcolor(BLUE);
outtextxy(0, 0, (LPCSTR)szOutText0);
} else {
setcolor(RED);
outtextxy(0, 0, (LPCSTR)szOutText1);
}
outtextxy(0, CELL_HEIGHT / 2, (LPCSTR)szOutText2);
GmDeinitialize();
while (1) {
/*keyMsg = getkey();
if (keyMsg.key == 'Y') {
GmInitialize();
break;
} else if (keyMsg.key == 'N') {
closegraph();
return 0;
}*/
if (keystate('Y')) {
GmInitialize();
break;
} else if (keystate('N')) {
closegraph();
return 0;
}
delay_ms(10);
}
}
}
}
}
FlushMouseMsgBuffer();
}
return 0;
}