path.h
来自「VIGASOCO (VIdeo GAmes SOurce COde) Windo」· C头文件 代码 · 共 38 行
H
38 行
// 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 + =
减小字号Ctrl + -
显示快捷键?