pathfinder.h

来自「一个基于A*算法的寻路类。完全C++实现。」· C头文件 代码 · 共 92 行

H
92
字号
/***********************
*    _PathFinder_h_    *
*    A* path finder    *
*    create by si.si   *
*       07.10.18       *
************************/

#ifndef _PathFinder_h_
#define _PathFinder_h_

#include "DList.h"

using namespace SSDataS;
//name space sisi's game AI
namespace SSGameAI
{
	struct Point
	{
		long x;
		long y;
	};

	typedef DListNode<Point> Path;

    //class PathFinder
	class PathFinder
	{
		//constructor and destructor
	public:
		PathFinder(int tlen , int* tArray , long SceneW , long SceneH , long mw , long mh);
		PathFinder();
		~PathFinder();

		//Set method
		void setTileLen( int tlen );
		void setTileArray( int* tArray );
		void setSceneWidth( long SceneW );
		void setSceneHeight( long SceneH );
		void setMaxRange( long mw , long mh );
		
		//get method
		int getTileLen() const;
		int getHalfTileLen() const;
		int* getTileArray() const;
		long getMaxStep() const;
		long getStepCount() const;
		long getSceneWidth() const;
		long getSceneHeight() const;
		long getSceneTWidth() const;
		long getSceneTHeight() const;

		//function method
		long makeTile( int x , int y );
		long getTileFromPos( Point pos );
		Point getPointFromTile(long t );
		long distance( Point StartPos , Point DestPos );
		long distance( long StartTile , long DestTile );
		Point adjustPos( Point pos );
		long* getAroundTile( Point pos );
		long getNearTile( Point pos , Point DestPos);
		bool movable( Point StartPos , Point DestPos , Path* &pPath , bool flags );
		Path* getLastMember( Path* pPath );
		bool isWalkableTile( long tileId );
		long doFor( long index , long flags );
		Point getNextPos( Point pos , long* RelateTile , long flags);
		bool isOldPos( Point NextPos , Path* pPath );
		void deletePath( Path* pPath );
		bool arcSearch( Point StartPos , Point DestPos , Path* &pPath , Path* pOldPath , long flags);
		bool roundSearch( Point StartPos , Point DestPos , Path* &pPath , long flags );
		Path* method1( Point pos , Point DestPos , long* get , long flags );
		Path* method2( Point pos , Point DestPos , long* get , long flags );
		Path* method3(SSGameAI::Point pos, SSGameAI::Point DestPos,Path* pPath1, long *get, long flags);
		bool getBasicPath( Point StartPos , Point DestPos , Path* &pPath, long* get , long flags );
		long getPathCount( Path* pPath );
		Path* getTheBestPath( Point StartPos , Point DestPos , long flags );

	private:
		int TileLen;
		int HalfTLen;
		int* TileArray;
		long MaxStep;
		long StepCount;
		long SceneWidth;
		long SceneHeight;
		long SceneTWidth;
		long SceneTHeight;
		long maxw;
		long maxh;
	};
};

#endif

⌨️ 快捷键说明

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