⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minewnd.h

📁 这是一个关于扫雷游戏的代码
💻 H
字号:
#if !defined(AFX_MINEWND_H__51E8BAA4_F785_466E_B059_85F775690B9A__INCLUDED_)
#define AFX_MINEWND_H__51E8BAA4_F785_466E_B059_85F775690B9A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MineWnd.h : header file
//

// defines

#define DEFAULT_FRAME_WIDTH      6
#define DEFAULT_FRAME_HEIGHT     63

#define RECT_X_0                 9
#define RECT_Y_0                 9
#define RECT_HEIGHT_0            37

#define RECT_X_1                 9
#define RECT_Y_1                 52

#define MINE_AREA_X              12
#define MINE_AREA_Y              55

#define SIDE_WIDTH_0             6
#define SIDE_WIDTH_1             5

#define LINE_WIDTH_0             3
#define LINE_WIDTH_1             2

#define MINE_WIDTH               16
#define MINE_HEIGHT              16

#define DRAW_NOT_OPEN            0
#define DRAW_FLAG                1
#define DRAW_QUESTION_MARK_FLAG  2
#define DRAW_BLAST               3
#define DRAW_ERROR_FLAG          4
#define DRAW_MINE                5
#define DRAW_QUESTION_MARK       6
#define DRAW_NUMBER_8            7
#define DRAW_NUMBER_7            8
#define DRAW_NUMBER_6            9
#define DRAW_NUMBER_5           10
#define DRAW_NUMBER_4           11
#define DRAW_NUMBER_3           12
#define DRAW_NUMBER_2           13
#define DRAW_NUMBER_1           14
#define DRAW_EMPTY              15

#define STATE_MINE               5
#define STATE_NUMBER_8           7
#define STATE_NUMBER_7           8
#define STATE_NUMBER_6           9
#define STATE_NUMBER_5           10
#define STATE_NUMBER_4           11
#define STATE_NUMBER_3           12
#define STATE_NUMBER_2           13
#define STATE_NUMBER_1           14
#define STATE_EMPTY              15
#define STATE_OPENED             16
#define EMPTY_AREA_START         1000

#define BUTTON_DOWN              0
#define BUTTON_VICTORY           1
#define BUTTON_DEAD              2
#define BUTTON_CLICK             3
#define BUTTON_NORMAL            4

#define ID_TIMER_EVENT           2004

// constant

const COLORREF COLOR_WHITE = RGB(255,255,255);
const COLORREF COLOR_GRAY = RGB(192,192,192);
const COLORREF COLOR_DARK_GRAY = RGB(128,128,128);
const COLORREF COLOR_BLACK = RGB(0,0,0);

enum {WAIT,RUN,DEAD,VICTORY};

// data struct
typedef struct 
{
	UINT uState;
	UINT uDraw;	
}MINE;


/////////////////////////////////////////////////////////////////////////////
// CMineWnd window

class CMineWnd : public CWnd
{
// Construction
public:
	CMineWnd();

// Implementation
protected:
	CMenu*    pSubMenu;  

	COLORREF  darkColor;
	CBitmap   BMP_NUMBER;
	CBitmap   BMP_BUTTON;
	CBitmap   BMP_MINEAREA;
	CBrush    backGroundBrush;

	UINT      uButtonPos[3];
	UINT      uButtonState; 
	BOOL      bHitButton;
    BOOL      bInButtonRect;

	UINT      uNumPos[6];
	UINT      uRectPosX[10];
	UINT      uRectPosY[10];

	MINE*     pMines;
	void*     pBlastWavMem;
	void*     pWinWavMem;
	void*     pCountWavMem;

	BOOL      bFirstClick;
    BOOL      bLoadWavRes;	 
	UINT      uTotle;
    UINT      uGameState;
	UINT      ClickNumber; 
	UINT_PTR  m_nTimer;	
	int       nOldPos;
    int       nNewPos;
	BOOL      bDoubleClick;
	BOOL      bInMineArea;
    BOOL      bRBUPOutMineArea;
	RECT      rect;

	// Attributes
public:	

// Operations
public:	
     void  MyCheckMenuItem();
	 void  MyCheckColorItem();
	 void  MyCheckMarkItem();
	 void  MyCheckSoundItem(); 

	 void  MyDrawRectangle( CPaintDC& dc );
	 void  MyDrawNumber( CPaintDC& dc );
	 void  MyDrawButton( CPaintDC& dc );
	 void  MyDrawMineArea( CPaintDC& dc );

	 void  SetWindowSize();
     void  SetPosition();
     void  SetBitmap();	 
	 void  ReAssign();
	 void  GameInit();

	 void  MyInvalidateRect( RECT &rectClick, int pos );
	 void  SetMineUp( int pos );
	 void  SetMineDown( int pos );
	 void  SetMineUpEx( int posArray[], int num );
	 void  SetMineDownEx( int posArray[], int num );
	 void  ChangeFlag( int pos );
	 
	 void  SetMine(int pos );
	 void  SetNumbers();
	 void  GetEmptyAreas();
	 void  DrawEmptyArea( UINT areaFlag );

	 BOOL  Victory();
	 void  FlagAllMine();
	 void  ProcessLeftButtonUp( int pos );
	 void  ProcessLeftRightButtonUp( int pos );

	 void  LoadWavRes();
	 void  FreeWavRes();
	 void  GetAroundPos( UINT i, int around[9]);
	 int   GetStation(int x,int y);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMineWnd)
	public:

	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CMineWnd();

	// Generated message map functions
protected:
	//{{AFX_MSG(CMineWnd)
	afx_msg void OnMenuAbout();
	afx_msg void OnMenuHelpList();
	afx_msg void OnMenuHelpUse();
	afx_msg void OnMenuHelpFind();
	afx_msg void OnMenuGameStart();
	afx_msg void OnMenuExit();	
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnMenuPrimary();
	afx_msg void OnMenuSecondary();
	afx_msg void OnMenuMark();
	afx_msg void OnMenuAdvanced();
	afx_msg void OnMenuColor();
	afx_msg void OnMenuCustom();
	afx_msg void OnMenuSound();	
	afx_msg void OnMenuHeroList();
	afx_msg void OnInitMenu(CMenu* pMenu);
	afx_msg void OnPaint();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnClose();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MINEWND_H__51E8BAA4_F785_466E_B059_85F775690B9A__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -