* Calculates the distance between the two given tiles. * * @param from The origin. * @param to The destination. * @return The longest distance between the X or Y coordinates, plus half the shortest. */
| 37 | * @return The longest distance between the X or Y coordinates, plus half the shortest. |
| 38 | */ |
| 39 | uint16 Tile_GetDistance(tile32 from, tile32 to) |
| 40 | { |
| 41 | uint16 distance_x = abs(from.x - to.x); |
| 42 | uint16 distance_y = abs(from.y - to.y); |
| 43 | |
| 44 | if (distance_x > distance_y) return distance_x + (distance_y / 2); |
| 45 | return distance_y + (distance_x / 2); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Adds two tiles together. |
no outgoing calls
no test coverage detected