📄 path.h
字号:
// Path.h
//
// Class with all path related methods
//
/////////////////////////////////////////////////////////////////////////////
#ifndef _PATH_H_
#define _PATH_H_
// this enumeration allows changing orientation easily with a xor 2
enum Orientation {
RIGHT = 0,
DOWN = 1,
LEFT = 2,
UP = 3
};
// this table has the (x, y) offsets for a move in any orientation
extern int movementOffsets[4][2];
class Path
{
// methods
public:
// calculates the square of the distance between 2 points
static int distance2(int p1X, int p1Y, int p2X, int p2Y);
// calculates the best path between two points, given an orientation
static void calcPath(int sourceX, int sourceY, Orientation ori, int destX, int destY,
int &movOffsX, int &movOffsY, Orientation &finalOri);
// calculates a random path, given a point and an orientation
static void calcRandomPath(int sourceX, int sourceY, Orientation ori,
int &movOffsX, int &movOffsY, Orientation &finalOri);
};
#endif // _PATH_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -