* Returns a number representing the direction from a starting tile to a neighbouring tile. * * Used in the pathfinding code, each step direction is assigned a number like this: * dx * -1 0 1 * +----- * -1|5 1 6 * dy 0|2 0 3 * 1|8 4 7 */
| 213 | * 1|8 4 7 |
| 214 | */ |
| 215 | int8_t GetPathDirection(Point startPosition, Point destinationPosition) |
| 216 | { |
| 217 | constexpr int8_t PathDirections[9] = { 5, 1, 6, 2, 0, 3, 8, 4, 7 }; |
| 218 | return PathDirections[3 * (destinationPosition.y - startPosition.y) + 4 + destinationPosition.x - startPosition.x]; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * @brief heuristic, estimated cost from startPosition to destinationPosition. |
no outgoing calls
no test coverage detected