Write mine-clearing games with VC + +

Source: Internet
Author: User
Tags bool exit resource sort

First, the most basic function of mine clearance is analyzed.

Click on the left mouse button in the unknown area, if the unknown area has thunder, game stop, show all the mines. If there is no thunder, then show the number of thunder around, if there is no thunder around, then look at the surrounding eight areas of thunder until there is thunder and show, this is actually a recursive process.

Click the right mouse button in the unknown area, then put it to have a thunder, whether or not there is a real ray. You can choose the first, middle, high three levels and customize the number of mines and the size of the area.

The upper left side of the minefield shows the number of mined areas indicated by the total number of mines.

The upper middle position of the minefield displays a button to start and display the results of the mouse action.

The upper right side of the minefield shows the time of mine clearance.

Clear all the Thunder, then show a dialog box to put your name in the list. Sorted by time.

To accomplish these functions, the specific technical details of applying Visual C + + are as follows:

1. Application APPW

Izard creates an SDI based application Cbombapp, removes print and status bar support, modifies menus and corresponding accelerator keys in the Resource editor to match Windows Minesweeper games. Specifically, start (Id-game-begin), Primary (Id-game-junior), Intermediate (Id-game-middle), Advanced (Id-game-senior), Custom (Id-game-custom), Color ( Id-game-color), Heroes List (Id-game-sort), exit (Id-game-exit), Help (Id-help).

2.13 properties in the resource editor for each small area of the mined area. Draw a corresponding 13 10 times 10 16-color small bitmap with a brush or other drawing tool. Three corresponding to the villain's expression of 20 times 20 of the 16-color small bitmap, for the replacement of color using a set with the first 16 corresponding monochrome bitmap, display time and number of 0~9 10 digital bitmap (background is black).

Custom Customer dialog box, which contains three static text controls and three edit controls, and three edit controls correspond to member M_irownum,m_icolumnnum,m_ibombnum. This dialog box is used to customize the number of numbers, the number of rows, and the corresponding MFC class is CCustomer. The Custom Sort dialog box contains nine static text controls, six of which display the name and time of the list, and the corresponding MFC class is Csort. The Custom Input dialog box, which contains a static text control and an edit control, is used to enter the name at the end of the game, and the corresponding MFC class is Cinput.

3. Define class bomb, encapsulate the related properties of each mine.

Class Bomb
{
public:
int isbomb;//决定初始时是否是雷
bool issel; //判断区域是否被处理过且周围有雷
bool isdone;//判断递归时是否被处理过
int num; //周围雷数
bool findbomb; //排雷者认为是雷时置一(但是不一定真是雷)
} ;

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.