VC + + Game development: Gobang

Source: Internet
Author: User

First, the operation of the program

Second, the computer in this program has the function of automatic judgment, according to the layout of the current pieces of the relevant way to use. In order to avoid the screen flashing at the time of walk, using double buffering for drawing output, the following is part of the software implementation code:

#include "stdafx.h"
The following data structures are defined in the Cfivechessview class:
enum {max_x = max_y=18, min_x =1, min_y = 1};

NONE: Empty location: Black White
enum {NONE = 0, black = 1, white = 2};
ATTACK: Offense: Defend: Defense
enum {ATTACK = 0, defend = 1};
Man_first: Black First: Computer_first: Baixian
enum {man_first = 0, Computer_first = 1};
Both_pease: And: Black_win: Black wins White_win: Baek Seung
enum {both_pease=0, Black_win = 1, White_win = 2};
L_to_r: Left to right t_to_b: top to bottom: Lb_to_rt: Lower left to upper right, LT_TO_RB top left to bottom right
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;
In the CMainFrame class PreCreateWindow (createstruct& CS) Adds the following code to set the fixed window size:
BOOL CMainFrame::P Recreatewindow (createstruct& CS)
{
if (! CFrameWnd::P Recreatewindow (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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.