📄 mainfrm.h
字号:
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__E9226E1B_9E6A_4BDC_BCA6_0F8C9D7E5987__INCLUDED_)
#define AFX_MAINFRM_H__E9226E1B_9E6A_4BDC_BCA6_0F8C9D7E5987__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//////////////////////////////////
//MINE DEF
//DIFFICULTY
//easy-style
#define EASY_XNUM 9
#define EASY_YNUM 9
#define EASY_MINENUM 10
//normal-style
#define NORMAL_XNUM 16
#define NORMAL_YNUM 16
#define NORMAL_MINENUM 40
//hard-style
#define HARD_XNUM 30
#define HARD_YNUM 16
#define HARD_MINENUM 99
//free-style
#define MAX_XNUM 24
#define MAX_YNUM 30
#define MAX_MINENUM 667
//FRAME SIZE
#define FRAMEX 6
#define FRAMEY 52
//WINDOW SIZE
#define SIDE 6
#define LINE 2
#define STATE_HEIGHT 40
//FACE SIZE AND POSITION
#define FACE_WIDTH 24
#define FACE_HEIGHT 24
#define FACEY 16
//NUMBER SIZE AND POSITION
#define NUMBER_WIDTH 13;
#define NUMBER_HEIGHT 23;
#define NUMBERY 16
//MINE SIZE
#define MINE_WIDTH 16
#define MINE_HEIGHT 16
//MINE STATE
#define NONECLICK 0
#define FLAG 1
#define QUESTION 2
#define BLAST 3
#define GAMEOVER 4
#define MINE 5
#define NONEUSE 6
#define EIGHT 7
#define SEVEN 8
#define SIX 9
#define FIVE 10
#define FOUR 11
#define THREE 12
#define TWO 13
#define ONE 14
#define EMPTY 15
//MOUSE STATE
#define DOWN 0
#define VICTORY 1
#define DEAD 2
#define CLICKED 3
#define NORMAL 4
//GAME STATE
#define GAMESTART 0
#define GAMEEND 1
#define GAMEWIN 2
//FUNCTION DEF
#define RANDTIME 300
//////////////////////////////
//////////////////////////////
//MINE STRUCT
typedef struct Mine{
//rand the mine use this attr
bool isMine;
//BFS or DFS use
bool isDetected;
//when draw the dc use that attr
int state;
//num or mine when open it
int hidestate;
}M;
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
private:
int d[8][2];
CRect clientRect;
int width,height;
int basic[3];
int mineXnum,mineYnum,minenum;
int bnstate,gamestate;
int leftgrid;
CBitmap mineColorBmp,faceColorBmp,numColorBmp;
M mine[MAX_XNUM][MAX_YNUM];
bool randmine[MAX_XNUM*MAX_YNUM];
int timer; //定时器标识
int ctime;
bool firstclick;
// Operations
public:
private:
void SizeWindow(void);
void initialMineArea(int x,int y,int m);
void DrawMineArea(CDC &dc);
void DrawFace(CDC &dc);
void DrawShell(CDC &dc);
void DrawNumber(CDC &dc);
int calState(int x,int y);
bool inArea(int x,int y){return x>=0&&x<mineYnum&&y>=0&&y<mineXnum;};
int getX(CPoint point){return (point.x-SIDE-LINE)/MINE_WIDTH;};
int getY(CPoint point){return (point.y-2*SIDE-3*LINE-STATE_HEIGHT)/MINE_HEIGHT;};
int click(int x,int y,CDC &dc);
void DFS(int x,int y);
bool inFaceButton(CPoint point){return (point.x>=(width-2*FRAMEX-FACE_WIDTH)/2&&point.x<=(width-2*FRAMEX+FACE_WIDTH)/2)&&point.y>=FACEY&&point.y<=FACEY+FACE_HEIGHT;};
bool inMineArea(CPoint point){return point.x>=SIDE+LINE&&point.x<=SIDE+LINE+mineXnum*MINE_WIDTH&&point.y>=2*SIDE+3*LINE+STATE_HEIGHT&&point.y<=2*SIDE+3*LINE+STATE_HEIGHT+MINE_HEIGHT*mineYnum;};
bool win(void){return leftgrid==0;};
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg void OnEasy();
afx_msg void OnNormal();
afx_msg void OnHard();
afx_msg void OnHelp();
afx_msg void OnPaint();
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnStart();
afx_msg void OnTimer(UINT nIDEvent);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__E9226E1B_9E6A_4BDC_BCA6_0F8C9D7E5987__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -