* Calculates the distance between 2 points. Rounded up to first INT. * @param pos1 Position of first square. * @param pos2 Position of second square. * @return Distance. */
| 2391 | * @return Distance. |
| 2392 | */ |
| 2393 | int TileEngine::distance(const Position &pos1, const Position &pos2) const |
| 2394 | { |
| 2395 | int x = pos1.x - pos2.x; |
| 2396 | int y = pos1.y - pos2.y; |
| 2397 | return (int)Round(sqrt(float(x*x + y*y))); |
| 2398 | } |
| 2399 | |
| 2400 | /** |
| 2401 | * Calculates the distance squared between 2 points. No sqrt(), not floating point math, and sometimes it's all you need. |
no test coverage detected