supertux/sector.cpp: Use Rectf::distance().
authorflorianf <florianf@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Sun, 28 Feb 2010 10:52:17 +0000 (10:52 +0000)
committerflorianf <florianf@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Sun, 28 Feb 2010 10:52:17 +0000 (10:52 +0000)
This is a lot cleaner.

git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6448 837edb03-e0f3-0310-88ca-d4d4e8b29345

src/supertux/sector.cpp

index 7d9178c..6cc7c7a 100644 (file)
@@ -1907,16 +1907,12 @@ Sector::get_nearest_player (const Vector& pos)
       ++playerIter)
   {
     Player *this_player = *playerIter;
-    float x_dist;
-    float y_dist;
     float this_dist;
 
     if (this_player->is_dying() || this_player->is_dead())
       continue;
 
-    x_dist = fabs ((this_player->get_pos ().x) - pos.x);
-    y_dist = fabs ((this_player->get_pos ().y) - pos.y);
-    this_dist = sqrtf (x_dist*x_dist + y_dist*y_dist);
+    this_dist = this_player->get_bbox ().distance (pos);
 
     if ((nearest_player == NULL) || (nearest_dist > this_dist)) {
       nearest_player = this_player;