一、程序运行时情况
开发:五子棋-vc++6.0">
二、本程序里的计算机具有自动判断的功能,能根据当前棋子的布局情况采用相关的 走子方式。为了避免在走子时候出现屏幕闪烁,采用双缓冲进行绘图输出,以下是软件实 现的部分代码:
#include "stdafx.h"
在CFiveChessView类中定义了如下的数据结构:
enum {MAX_X = 18, MAX_Y=18, MIN_X =1, MIN_Y =1};
// NONE :空位置:BLACK :黑 WHITE 白
enum {NONE = 0, BLACK = 1, WHITE = 2};
// ATTACK :进攻:DEFEND :防守
enum {ATTACK = 0, DEFEND = 1};
// MAN_FIRST :黑先:COMPUTER_FIRST :白先
enum {MAN_FIRST = 0, COMPUTER_FIRST = 1};
// BOTH_PEASE :和:BLACK_WIN :黑胜 WHITE_WIN: 白胜
enum {BOTH_PEASE=0, BLACK_WIN = 1, WHITE_WIN = 2};
// L_TO_R:左到右 T_TO_B :上到下: LB_TO_RT :左下到右上,LT_TO_RB左上到右 下
enum {L_TO_R=0, T_TO_B = 1, LB_TO_RT = 2 , LT_TO_RB = 3};
CChess fiveChess;
int m_nLastBlackPos_x;
int m_nLastBlackPos_y;
int m_nCurrentWhitePos_x;
int m_nCurrentWhitePos_y;
在CMainFrame类中PreCreateWindow(CREATESTRUCT& cs)增加如下代码设置固定窗口 大小:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.style = WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX;// | WS_THICKFRAME;
cs.style &= ~WS_BORDER;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
int iWinBorderX = GetSystemMetrics(SM_CXBORDER);
int iWinBorderY = GetSystemMetrics(SM_CYBORDER);
int iCaptionY = GetSystemMetrics(SM_CYCAPTION);
int iMenuY = GetSystemMetrics(SM_CYMENU);
int iStausY = GetSystemMetrics(SM_CYMENU);
cs.cx = 510 + iWinBorderX ;
cs.cy = 530 + iWinBorderY + iCaptionY + iStausY + iMenuY;
return TRUE;
}