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

📄 qiyuanview.h

📁 利用人工智能的经典算法实现迷宫游戏;里面的A星(a*)算法可以很方便的移植到应用程序中
💻 H
字号:
// qiyuanView.h : interface of the CQiyuanView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_QIYUANVIEW_H__5CEF5CD0_EB04_4F3B_B83C_E558F6A7BF86__INCLUDED_)
#define AFX_QIYUANVIEW_H__5CEF5CD0_EB04_4F3B_B83C_E558F6A7BF86__INCLUDED_

#include "maze.h"	// Added by ClassView

#include "list_node1.h"
#include "m_list.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//定义颜色用于画图
#define WHITE RGB(255,255,255)
#define BLACK RGB(0,0,0)
#define BLUE  RGB(0,0,255)
#define	SetWin RGB(0,0,0)
#define BGColor RGB(0,255,0)
#define SMALLAREA 2


class CQiyuanView : public CView
{
protected: // create from serialization only
	int index1,index2;
	CQiyuanView();
	DECLARE_DYNCREATE(CQiyuanView)

// Attributes
public:
	CQiyuanDoc* GetDocument();

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CQiyuanView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	//}}AFX_VIRTUAL

// Implementation
public:
	int LoadCar();
	int CreateMaze();
	int GameSet();
	int GameRun();
	maze ViewMaze;//定义用户迷宫
	maze ArtificialMaze[10];//人工地图定义
//定义各种位图包括墙,小车等		
	CBitmap wall;
	CBitmap car;
	CBitmap RoadBMP;
	CBitmap goal;
	CBitmap start;
	CBitmap walkedroad;
	BITMAP bmp1;
	int Astep;
	int CarStep;
	int dg_n;
	UINT UserSpeed;
list_node     * open_list;
list_node    * closed_list;
list_node    * road_list;
list_node    * sub_nodes;
//初始化操作(未使用的)
//	GameInitnal();      //游戏的初始化
//状态控制操作
//	GameStart();         //游戏开始
//	GamePause();         //游戏暂停
//	GameEnd();           //游戏结束
static		int  OnHelpAbout();		//关于对话框函数
 list_node * Asearch(int a[][MOSTNUM],CPoint s_n,CPoint s_g);//A*搜索的程序
	virtual ~CQiyuanView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	CDC m_memDC;                   //内存设备环境 
	CBitmap m_memBmp;              //内存位图,用于将整幅图在内存中画出后画到屏幕上

	CDC m_memRectDC;        //方块内存设备环境
	HBITMAP m_hMemRectBmp;  //方块内存位图句柄
	int m_FistPlay;    //是否是第一次开始游戏标记,用于初始化
	int FirstGame;     //是否是第一迷宫标记,用于初始化
	int FoundWayFlag;  //是否找到路径标记
	int HaveFoundFlag; //是否找过路径标记
	int GameStartFlag;//是否开始
	int GameEndFlag;    //是否结束
	int GamePauseFlag;//是否暂停
	int	GameResumeFlag;//是否继续
	int ArtificialMapFlag;//人工地图标记
	int ArtificialWalkFlag;//人工行走标记
	int ArtificialMap;//人工地图标记
	int m_Game;//是否开始游戏
	int OnTheEndFlag;//是否到达终点



	int m_WinWidth;//窗口大小
	int m_WinHeight;//窗口大小
	int m_SetWinWidth;//右端设置窗口的宽度
	int m_SetWinHeight;//右端设置窗口的高度
	int m_MazeWinWidth;//右端设置窗口的宽度
	int m_MazeWinHeight;//右端设置窗口的高度
	int MapWidth;//迷宫格宽度
	int MapHeight;//迷宫格高度
	float UserSetWallNum;//设置的墙的密度
	UINT ArtificialDire;//人工运动方向
	int  RobotNum;//选择第几个机器人

//定义的函数

	int  DrawGame(CDC *pDC);//画图函数
	int  DCEnvClear();		//删除设备句柄函数
	int  DcEnvInitial();	//初始化设备句柄函数
	int  GameNew();			//新建游戏函数

//定义的画刷,OnDraw中需要用到的设备名称
	CPen   *m_pBlackPen;
	CPen   *m_pSetWinPen;

	CBrush *m_pWhiteBrush;
	CBrush *m_pBlackBrush;
	CBrush *m_pSetWinBrush;
	CBrush *m_pBGBrush;
	
protected:

//是否插放背景音乐
	BOOL m_bMusic;

//迷宫搜索总时间
	int m_SearchTime;

//游戏是否已结束,为FALSE表示开始,否则为结束
	BOOL m_GameEnd;
//{{AFX_MSG(CQiyuanView)
	afx_msg void OnNewGameSet();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnAboutDialog();
	afx_msg void OnUpdateAbout(CCmdUI* pCmdUI);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnGameStart();
	afx_msg void OnGamePause();
	afx_msg void OnGameResume();
	afx_msg void OnTest();
	afx_msg void OnChooseRobot();
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in qiyuanView.cpp
inline CQiyuanDoc* CQiyuanView::GetDocument()
   { return (CQiyuanDoc*)m_pDocument; }
#endif

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

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

#endif // !defined(AFX_QIYUANVIEW_H__5CEF5CD0_EB04_4F3B_B83C_E558F6A7BF86__INCLUDED_)

⌨️ 快捷键说明

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