C++實現圖形界面五子棋遊戲源碼2

C++圖形界面五子棋, Shell控制檯實現五子棋的基礎上引用了圖形庫源碼。

如需安裝c++或遠程調試,可加QQ905733049由專業技術人員遠程協助!

源碼如下:

/******************************************
*******程序名稱:單機遊戲:五子棋(人人對戰)
*******作者    :
*******開發環境:Visual Studio 2017
*******創建日期:2018.06.02
*******完成日期:2018.06.10
*******************************************/

#include "stdio.h"
#include "conio.h"
#include "windows.h"

void init_system();//初始化系統
void close_system();//關閉系統
void init_globales();//初始化參數

void play_chess();//開始五子棋遊戲
void gamestart();//開始下棋
int  count_xyk_by_message(MOUSEMSG *m, int *x, int *y, int *a, int *b);//計算鼠標所在區域狀態
int  judge(int a, int b, int c, int chess[][15]);//判斷勝負條件
void regret(int x2, int y2, int chess[15][15], int chessbox[][2]);//悔棋

void draw_chessmen(int x, int y, int num, int a, int b, int chess[][15]);//繪製黑白棋子
void draw_chessboard();//畫棋盤、菜單、狀態框,畫標題
void text();//繪製標題
void draw_menu();//繪製菜單
void over_white();//繪製白棋勝字樣
void position();//繪製狀態欄及內容
void text_black();//繪製黑棋下字樣
void text_white();//繪製白棋下字樣
void draw_regret(int m, int n, int x2, int y2);//所有悔棋情況
void draw_re(int x2, int y2);//繪製悔棋棋子

int m_x0, m_y0, m_wh = 40, m_x01, m_y01;//對戰區座標
int m_x_chess, m_y_chess, m_x_chess1, m_y_chess1;//可下棋座標
int m_row = 14, m_row1 = 15;
int num = 0;//步數
int chessbox[255][2];


#define GAME_RUNNING     1
#define GAME_OVER        0  
#define MOUSE_POS_ELSE   99
#define MOUSE_POS_AREA   1
#define NUM_BLACK        10
#define NUM_WHITE        20
#define MOUSE_POS_START  100
#define MOUSE_POS_REGRET 200


int  main()
{
	init_system();

	draw_chessboard();

	play_chess();

	close_system();

	return 0;
}
/*================================================
== 函數名:init_system()
== 功  能:初始化系統
== 參  數:無
== 返回值:無
=================================================*/
void init_system()
{
	initgraph(1024, 768);
	init_globales();
}
/*================================================
== 函數名:close_system()
== 功  能:關閉系統
== 參  數:無
== 返回值:無
=================================================*/
void close_system()
{
	_getch();
	closegraph();
}
/*================================================
== 函數名:init_globales()
== 功  能:初始化參數
== 參  數:無
== 返回值:無
=================================================*/
void init_globales()
{
	m_x0 = 1024 / 2 - (m_row / 2) * m_wh;/*小棋盤*/
	m_x01 = m_x0 + m_row * m_wh;
	m_y0 = 768 / 2 - (m_row / 2) * m_wh;
	m_y01 = m_y0 + m_row * m_wh;

	m_x_box = m_x0 - m_wh;/*大棋盤*/
	m_x_box1 = m_x01 + m_wh;
	m_y_box = m_y0 - m_wh * 2;
	m_y_box1 = m_y01 + m_wh;

	m_x_chess = m_x0 - m_wh / 2;/*可下棋區域*/
	m_y_chess = m_y0 - m_wh / 2;
	m_x_chess1 = m_x01 + m_wh / 2;
	m_y_chess1 = m_y01 + m_wh / 2;
}
/*================================================
== 函數名:draw_chessboard()
== 功  能:畫棋盤、菜單、狀態框,畫標題
== 參  數:無
== 返回值:無
=================================================*/
void draw_chessboard()
{
	int i;
	//	loadimage(NULL, "E:\\個人\\PICTURE\\123.jpg");
	setbkcolor(BLACK);
	cleardevice();/*用背景色清空屏幕*/
	setlinestyle(PS_SOLID, 1);
	setlinecolor(WHITE);
	rectangle(m_x_box, m_y_box, m_x_box1, m_y_box1);
	setfillcolor(RGB(172, 81, 24));
	setfillstyle(BS_SOLID);
	floodfill((m_x0 + m_x01) / 2, (m_y0 + m_y01) / 2, WHITE);

	setlinestyle(PS_SOLID, 2);
	setlinecolor(BLACK);
	rectangle(m_x0 - 4, m_y0 - 4, m_x01 + 4, m_y01 + 4);

	setlinestyle(PS_SOLID, 1);
	setlinecolor(BLACK);
	rectangle(m_x0, m_y0, m_x01, m_y01);

	for (i = m_x0 + m_wh; i < m_x01; i += m_wh)//繪製交叉線
	{
		line(i, m_y0, i, m_y01);
	}
	for (i = m_y0 + m_wh; i < m_y01; i += m_wh)
	{
		line(m_x0, i, m_x01, i);
	}

	setlinecolor(BLACK);
	setfillcolor(BLACK);/*繪製畫筆顏色以及填充顏色*/

	fillcircle(m_x0 + m_wh * 3, m_y0 + m_wh * 3, 3);//繪製星位
	fillcircle(m_x0 + m_wh * 11, m_y0 + m_wh * 3, 3);
	fillcircle(m_x0 + m_wh * 3, m_y0 + m_wh * 11, 3);
	fillcircle(m_x0 + m_wh * 11, m_y0 + m_wh * 11, 3);
	fillcircle(m_x0 + m_wh * 7, m_y0 + m_wh * 7, 3);

	draw_menu();/*繪製菜單*/
	position();/*繪製狀態框*/
	text();/*繪製標題*/
}
/*================================================
== 函數名:play_chess()
== 功  能:開始五子棋遊戲
== 參  數:無
== 返回值:無
=================================================*/
void play_chess()
{
	int x, y;//鼠標座標
	int pos;//鼠標狀態
	int a, b;
	MOUSEMSG m;
	while (1)
	{
		m = GetMouseMsg();
		pos = count_xyk_by_message(&m, &x, &y, &a, &b);

		switch (m.uMsg)
		{
		case WM_LBUTTONDOWN:/*判別鼠標左鍵點擊區域*/
		{
			if (pos == MOUSE_POS_ELSE)  continue;//其他區域
			if (pos == MOUSE_POS_START) gamestart();//開始方框
			if (pos == GAME_OVER) exit(1);//結束方框
		}
		}
	}
}
/*================================================
== 函數名:gamestart()
== 功  能:開始下棋
== 參  數:無
== 返回值:無
=================================================*/
void gamestart()
{
	draw_chessboard();

	int chess[15][15] = { 0 };
	num = 0;

	int x1, y1;
	x1 = m_x0 + m_wh * (m_row + 2);
	y1 = m_y0 + m_wh * 5;
	TCHAR str[] = _T("請下棋");
	settextstyle(m_wh, m_wh / 2 - 1, _T("楷體"));
	setbkmode(OPAQUE);
	settextcolor(WHITE);
	outtextxy(x1 + 1, y1, str);

	int x, y;//鼠標座標
	int pos;//鼠標狀態
	int x2, y2;
	int a, b;
	int mstate = GAME_RUNNING;
	MOUSEMSG m;
	IMAGE img;

	while (1)
	{
		m = GetMouseMsg();
		pos = count_xyk_by_message(&m, &x, &y, &a, &b);

		switch (m.uMsg)
		{
		case WM_LBUTTONDOWN:
		{
			if (pos == MOUSE_POS_AREA)
			{
				if (chess[a][b] == NUM_BLACK || chess[a][b] == NUM_WHITE) continue;
				else
				{
					draw_chessmen(x, y, num, a, b, chess);
					chessbox[num][0] = a;
					chessbox[num][1] = b;
					if (num % 2 == 0)
					{
						text_white();
					}
					if (num % 2 != 0)
					{
						text_black();
					}
					num++;
					x2 = x;
					y2 = y;
					if (judge(a, b, NUM_BLACK, chess))
					{
						over_black();
						return;
					}
					if (judge(a, b, NUM_WHITE, chess))
					{
						over_white();
						return;
					}
				}
			}
			if (pos == MOUSE_POS_REGRET)
			{
				regret(x2, y2, chess, chessbox);
			}

		}break;
		}
	}
}
/*============================================================================
== 函數名:count_xyk_by_message(MOUSEMSG *m, int *x, int *y, int *a, int *b)
== 功  能:計算鼠標所在區域狀態
== 參  數:MOUSEMSG *m:鼠標信息
		  int *x, int *y:交叉點橫縱座標
		  int *a, int *b:交叉點對應二維數組下標
== 返回值:MOUSE_POS_AREA  :可下棋區域
		  MOUSE_POS_START :菜單開始方框
		  MOUSE_POS_REGRET:菜單悔棋方框
		  GAME_OVER       :菜單結束方框
		  MOUSE_POS_ELSE  :非功能區域
==============================================================================*/
int  count_xyk_by_message(MOUSEMSG *m, int *x, int *y, int *a, int *b)
{
	int x1, y1;

	x1 = m->x;
	y1 = m->y;

	if ((x1 >= m_x_chess && x1 <= m_x_chess1)
		&& (y1 >= m_y_chess && y1 <= m_y_chess1))
	{
		*x = m_x0 + (m->x - m_x_chess) / m_wh * m_wh;
		*y = m_y0 + (m->y - m_y_chess) / m_wh * m_wh;

		*b = (*x - m_x_chess) / m_wh;
		*a = (*y - m_y_chess) / m_wh;

		return (MOUSE_POS_AREA);
	}

	if ((x1 >= m_x0 - m_wh * 4 && x1 <= m_x0 - m_wh * 2)
		&& (y1 >= m_y0 + m_wh * 3 && y1 <= m_y0 + m_wh * 4))
		return (MOUSE_POS_START);

	if ((x1 >= m_x0 - m_wh * 4 && x1 <= m_x0 - m_wh * 2)
		&& (y1 >= m_y0 + m_wh * 5 && y1 <= m_y0 + m_wh * 6))
		return (MOUSE_POS_REGRET);

	if ((x1 >= m_x0 - m_wh * 4 && x1 <= m_x0 - m_wh * 2)
		&& (y1 >= m_y0 + m_wh * 7 && y1 <= m_y0 + m_wh * 8))
		return (GAME_OVER);

	return (MOUSE_POS_ELSE);
}
/*=========================================================================
== 函數名:void regret(int x2, int y2, int chess[15][15],int chessbox[][2])
== 功  能:悔棋
== 參  數:int x2, int y2:棋子所在的交叉點座標
		  int chess[15][15]:交叉點棋子信息(判定是黑、白、無棋)
		  int chessbox[][2]:上一棋子數組下標
== 返回值:無
==========================================================================*/
void regret(int x2, int y2, int chess[15][15], int chessbox[][2])
{
	int m, n;
	m = chessbox[num - 1][0];
	n = chessbox[num - 1][1];
	draw_regret(m, n, x2, y2);
	chess[m][n] = 0;
	num = num - 1;

	if (num % 2 == 0)
	{
		text_black();
	}
	if (num % 2 != 0)
	{
		text_white();
	}
}
/*================================================
== 函數名:draw_regret(int m, int n, int x2, int y2)
== 功  能:繪製所有悔棋情況
== 參  數:int m, int n:棋子所在交叉點下標
		  int x2, int y2:棋子所在交叉點座標
== 返回值:無
=================================================*/
void draw_regret(int m, int n, int x2, int y2)
{
	draw_re(x2, y2);
	if (m == 3 && n == 3)
	{
		setlinecolor(BLACK);
		setfillcolor(BLACK);/*繪製畫筆顏色以及填充顏色*/
		fillcircle(m_x0 + m_wh * 3, m_y0 + m_wh * 3, 3);//繪製星位
	}
	if (m == 3 && n == 11)
	{
		setlinecolor(BLACK);
		setfillcolor(BLACK);/*繪製畫筆顏色以及填充顏色*/
		fillcircle(m_x0 + m_wh * 11, m_y0 + m_wh * 3, 3);
	}
	if (m == 11 && n == 3)
	{
		setlinecolor(BLACK);
		setfillcolor(BLACK);/*繪製畫筆顏色以及填充顏色*/
		fillcircle(m_x0 + m_wh * 3, m_y0 + m_wh * 11, 3);
	}
	if (m == 11 && n == 11)
	{
		setlinecolor(BLACK);
		setfillcolor(BLACK);/*繪製畫筆顏色以及填充顏色*/
		fillcircle(m_x0 + m_wh * 11, m_y0 + m_wh * 11, 3);
	}
	if (m == 7 && n == 7)
	{
		setlinecolor(BLACK);
		setfillcolor(BLACK);/*繪製畫筆顏色以及填充顏色*/
		fillcircle(x2, y2, 3);
	}
	if (m == 0 && n == 0)
	{
		setlinecolor(RGB(172, 81, 24));
		setlinestyle(PS_SOLID, 1);
		line(x2, y2, x2 - 15, y2);
		line(x2, y2, x2, y2 - 15);
		setlinestyle(PS_SOLID, 2);
		setlinecolor(BLACK);
		rectangle(m_x0 - 4, m_y0 - 4, m_x01 + 4, m_y01 + 4);
	}
	if (m == 0 && n == 14)
	{
		setlinecolor(RGB(172, 81, 24));
		setlinestyle(PS_SOLID, 1);
		line(x2, y2, x2 + 15, y2);
		line(x2, y2, x2, y2 - 15);
		setlinestyle(PS_SOLID, 2);
		setlinecolor(BLACK);
		rectangle(m_x0 - 4, m_y0 - 4, m_x01 + 4, m_y01 + 4);
	}
	if (m == 14 && n == 0)
	{
		setlinecolor(RGB(172, 81, 24));
		setlinestyle(PS_SOLID, 1);
		line(x2, y2, x2 - 15, y2);
		line(x2, y2, x2, y2 + 15);
		setlinestyle(PS_SOLID, 2);
		setlinecolor(BLACK);
		rectangle(m_x0 - 4, m_y0 - 4, m_x01 + 4, m_y01 + 4);
	}
	if (m == 14 && n == 14)
	{
		setlinecolor(RGB(172, 81, 24));
		setlinestyle(PS_SOLID, 1);
		line(x2, y2, x2 + 15, y2);
		line(x2, y2, x2, y2 + 15);
		setlinestyle(PS_SOLID, 2);
		setlinecolor(BLACK);
		rectangle(m_x0 - 4, m_y0 - 4, m_x01 + 4, m_y01 + 4);
	}
	if ((n > 0 && n < 14) && m == 0)
	{
		setlinecolor(RGB(172, 81, 24));
		setlinestyle(PS_SOLID, 1);
		line(x2, y2, x2, y2 - 15);
		setlinestyle(PS_SOLID, 2);
		setlinecolor(BLACK);
		rectangle(m_x0 - 4, m_y0 - 4, m_x01 + 4, m_y01 + 4);
	}
	if ((n > 0 && n < 14) && m == 14)
	{
		setlinecolor(RGB(172, 81, 24));
		setlinestyle(PS_SOLID, 1);
		line(x2, y2, x2, y2 + 15);
		setlinestyle(PS_SOLID, 2);
		setlinecolor(BLACK);
		rectangle(m_x0 - 4, m_y0 - 4, m_x01 + 4, m_y01 + 4);
	}
	if ((m > 0 && m < 14) && n == 0)
	{
		setlinecolor(RGB(172, 81, 24));
		setlinestyle(PS_SOLID, 1);
		line(x2, y2, x2 - 15, y2);
		setlinestyle(PS_SOLID, 2);
		setlinecolor(BLACK);
		rectangle(m_x0 - 4, m_y0 - 4, m_x01 + 4, m_y01 + 4);
	}
	if ((m > 0 && m < 14) && n == 14)
	{
		setlinecolor(RGB(172, 81, 24));
		setlinestyle(PS_SOLID, 1);
		line(x2, y2, x2 + 15, y2);
		setlinestyle(PS_SOLID, 2);
		setlinecolor(BLACK);
		rectangle(m_x0 - 4, m_y0 - 4, m_x01 + 4, m_y01 + 4);
	}
}
/*================================================
== 函數名:draw_re(int x2, int y2)
== 功  能:繪製悔棋棋子
== 參  數:int x2, int y2:棋子所在交叉點座標
== 返回值:無
=================================================*/
void draw_re(int x2, int y2)
{
	setlinecolor(RGB(172, 81, 24));
	setfillcolor(RGB(172, 81, 24));
	fillcircle(x2, y2, 15);
	setlinecolor(BLACK);
	setlinestyle(PS_SOLID, 1);
	line(x2 - 15, y2, x2 + 15, y2);
	line(x2, y2 - 15, x2, y2 + 15);
}
/*=============================================================================
== 函數名:draw_chessmen(int x, int y, int num, int a, int b, int chess[][15])
== 功  能:繪製黑白棋子
== 參  數:int x, int y   :下棋交叉點橫縱座標
		  int num        :棋子數
		  int a, int b   :交叉點數組下標
		  int chess[][15]:交叉點數組信息
== 返回值:無
===============================================================================*/
void draw_chessmen(int x, int y, int num, int a, int b, int chess[][15])
{
	if (num % 2 == 0)
	{
		setlinecolor(BLACK);
		setfillcolor(BLACK);
		fillcircle(x, y, 15);
		chess[a][b] = NUM_BLACK;
	}

	if (num % 2 != 0)
	{
		setlinecolor(WHITE);
		setfillcolor(WHITE);
		fillcircle(x, y, 15);
		chess[a][b] = NUM_WHITE;
	}
}
/*================================================
== 函數名:text()
== 功  能:繪製標題
== 參  數:無
== 返回值:無
=================================================*/
void text()
{
	int x1, y1;
	TCHAR str[] = _T("五 子 棋");
	settextstyle(m_wh, m_wh, _T("黑體"));
	setbkcolor(RGB(172, 81, 24));
	settextcolor(BLACK);
	x1 = m_x0 + m_wh * 3;
	y1 = m_y0 - m_wh / 3 * 2 - 30;
	outtextxy(x1, y1, str);
}
/*================================================
== 函數名:judge(int a, int b, int c, int chess[][15])
== 功  能:判斷勝負條件
== 參  數:int a,int b   :數組下標(代表行和列)
		  int c          :代表顏色
		  int chess[][15]:代表棋子顏色
== 返回值:無
=================================================*/
int  judge(int a, int b, int c, int chess[][15])
{
	int i, j, n1, n2; //i 表示行,j表示列
	while (1)
	{
		n1 = 0;
		n2 = 0;
		/*水平向左統計同種顏色棋子個數*/
		for (i = a, j = b; j >= 0; j--)
		{
			if (chess[i][j] == c)
				n1++;
			else
				break;
		}
		/*水平向右統計同種顏色棋子個數*/
		for (i = a, j = b; j <= m_row1; j++)
		{
			if (chess[i][j] == c)
				n2++;
			else
				break;
		}
		if (n1 + n2 - 1 >= 5)
		{
			return(1);
			break;
		}
		/*垂直向上統計同種顏色棋子個數*/
		n1 = 0;
		n2 = 0;
		for (i = a, j = b; i >= 0; i--)
		{
			if (chess[i][j] == c)
				n1++;
			else
				break;
		}
		/*垂直向下統計同種顏色棋子個數*/
		for (i = a, j = b; i <= m_row1; i++)
		{
			if (chess[i][j] == c)
				n2++;
			else
				break;
		}
		if (n1 + n2 - 1 >= 5)
		{
			return(1);
			break;
		}
		/*向左上方統計同種顏色棋子個數*/
		n1 = 0;
		n2 = 0;
		for (i = a, j = b; i >= 0, j >= 0; i--, j--)
		{
			if (chess[i][j] == c)
				n1++;
			else
				break;
		}
		/*向右下方統計同種顏色棋子個數*/
		for (i = a, j = b; i <= m_row1, j <= m_row1; i++, j++)
		{
			if (chess[i][j] == c)
				n2++;
			else
				break;
		}
		if (n1 + n2 - 1 >= 5)
		{
			return(1);
			break;
		}
		/*向右上方統計同種顏色棋子個數*/
		n1 = 0;
		n2 = 0;
		for (i = a, j = b; i >= 0, j <= m_row1; i--, j++)
		{
			if (chess[i][j] == c)
				n1++;
			else
				break;
		}
		/*向左下方統計同種顏色棋子個數*/
		for (i = a, j = b; i <= m_row1, j >= 0; i++, j--)
		{
			if (chess[i][j] == c)
				n2++;
			else
				break;
		}

		if (n1 + n2 - 1 >= 5)
		{
			return(1);
			break;
		}
		return(0);
		break;
	}
}
/*================================================
== 函數名:draw_menu()
== 功  能:繪製菜單
== 參  數:無
== 返回值:無
=================================================*/
void draw_menu()
{
	int x, y;

	setlinestyle(PS_SOLID, 1);
	setlinecolor(WHITE);

	x = m_x0 - m_wh * 4;
	y = m_y0 + m_wh * 3;
	rectangle(x, y, x + m_wh * 2, y + m_wh);//開始方框
	setfillcolor(RGB(172, 81, 24));
	setfillstyle(BS_SOLID);
	floodfill(x + 1, y + 1, WHITE);
	TCHAR str1[] = _T("開始");
	settextstyle(m_wh - 2, m_wh / 2 - 2, _T("楷體"));
	setbkcolor(RGB(172, 81, 24));
	settextcolor(BLACK);
	outtextxy(x + 4, y + 1, str1);

	x = x;
	y = y + m_wh * 2;
	rectangle(x, y, x + m_wh * 2, y + m_wh);//悔棋方框
	setfillcolor(RGB(172, 81, 24));
	setfillstyle(BS_SOLID);
	floodfill(x + 1, y + 1, WHITE);
	TCHAR str2[] = _T("悔棋");
	settextstyle(m_wh - 2, m_wh / 2 - 2, _T("楷體"));
	setbkcolor(RGB(172, 81, 24));
	settextcolor(BLACK);
	outtextxy(x + 4, y + 1, str2);

	x = x;
	y = y + m_wh * 2;
	rectangle(x, y, x + m_wh * 2, y + m_wh);//結束方框
	setfillcolor(RGB(172, 81, 24));
	setfillstyle(BS_SOLID);
	floodfill(x + 1, y + 1, WHITE);
	TCHAR str3[] = _T("結束");
	settextstyle(m_wh - 2, m_wh / 2 - 2, _T("楷體"));
	setbkcolor(RGB(172, 81, 24));
	settextcolor(BLACK);
	outtextxy(x + 4, y + 1, str3);

}
/*================================================
== 函數名:over_black()
== 功  能:繪製黑棋勝字樣
== 參  數:無
== 返回值:無
=================================================*/
void over_black()
{
	int x, y;
	x = m_x0 + m_wh * (m_row + 2);
	y = m_y0 + m_wh * 5;
	TCHAR str[] = _T("黑方勝");
	settextstyle(m_wh, m_wh / 2 - 1, _T("楷體"));
	setbkmode(OPAQUE);
	settextcolor(WHITE);
	outtextxy(x + 1, y, str);
	TCHAR str1[] = _T("按開始再來一局");
	settextstyle(m_wh / 2, m_wh / 5 - 1, _T("黑體"));
	setbkmode(OPAQUE);
	settextcolor(WHITE);
	x = m_x0 + m_wh * (m_row + 2) + 7;
	y = m_y0 + m_wh * 6;
	outtextxy(x + 1, y, str1);
}
/*================================================
== 函數名:over_white()
== 功  能:繪製白棋勝字樣
== 參  數:無
== 返回值:無
=================================================*/
void over_white()
{
	int x, y;
	x = m_x0 + m_wh * (m_row + 2);
	y = m_y0 + m_wh * 5;
	TCHAR str[] = _T("白方勝");
	settextstyle(m_wh, m_wh / 2 - 1, _T("楷體"));
	setbkmode(OPAQUE);
	settextcolor(WHITE);
	outtextxy(x + 1, y, str);
	TCHAR str1[] = _T("按開始再來一局");
	settextstyle(m_wh / 2, m_wh / 5 - 1, _T("黑體"));
	setbkmode(OPAQUE);
	settextcolor(WHITE);
	x = m_x0 + m_wh * (m_row + 2) + 7;
	y = m_y0 + m_wh * 6;
	outtextxy(x + 1, y, str1);
}
/*================================================
== 函數名:position()
== 功  能:繪製狀態欄及內容
== 參  數:無
== 返回值:無
=================================================*/
void position()
{
	int x, y;
	x = m_x0 + m_wh * (m_row + 2);
	y = m_y0 + m_wh * 4;
	setlinecolor(WHITE);
	rectangle(x, y, x + m_wh * 3, y + m_wh * 3);
	setfillcolor(RGB(172, 81, 24));
	setfillstyle(BS_SOLID);
	floodfill(x + 1, y + 1, WHITE);

	TCHAR str1[] = _T("提示");
	settextstyle(m_wh / 2, m_wh / 3, _T("楷體"));
	setbkmode(TRANSPARENT);
	settextcolor(WHITE);
	outtextxy(x + m_wh / 3 * 2, y + 2, str1);

	x = x;
	y = y + m_wh;
	TCHAR str[] = _T("請點擊開始");
	settextstyle(m_wh, m_wh / 3 - 2, _T("楷體"));
	setbkmode(TRANSPARENT);
	settextcolor(WHITE);
	outtextxy(x, y, str);


}
/*================================================
== 函數名:text_black()
== 功  能:繪製黑棋下字樣
== 參  數:無
== 返回值:無
=================================================*/
void text_black()
{
	int x, y;
	x = m_x0 + m_wh * (m_row + 2);
	y = m_y0 + m_wh * 5;
	TCHAR str[] = _T("黑子下");
	settextstyle(m_wh, m_wh / 2 - 1, _T("楷體"));
	setbkmode(OPAQUE);
	settextcolor(WHITE);
	outtextxy(x + 1, y, str);
}
/*================================================
== 函數名:text_white()
== 功  能:繪製白棋下字樣
== 參  數:無
== 返回值:無
=================================================*/
void text_white()
{
	int x, y;
	x = m_x0 + m_wh * (m_row + 2);
	y = m_y0 + m_wh * 5;
	TCHAR str[] = _T("白子下");
	settextstyle(m_wh, m_wh / 2 - 1, _T("楷體"));
	setbkmode(OPAQUE);
	settextcolor(WHITE);
	outtextxy(x + 1, y, str);
}

實現效果如圖:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章