return gravity;
}
+Player *
+Sector::get_nearest_player (const Vector& pos)
+{
+ Player *nearest_player;
+ float nearest_dist;
+
+ nearest_player = NULL;
+
+ std::vector<Player*> players = Sector::current()->get_players();
+ for (std::vector<Player*>::iterator playerIter = players.begin();
+ playerIter != players.end();
+ ++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);
+
+ if ((nearest_player == NULL) || (nearest_dist > this_dist)) {
+ nearest_player = this_player;
+ nearest_dist = this_dist;
+ }
+ }
+
+ return (nearest_player);
+} /* Player *get_nearest_player */
+
/* vim: set sw=2 sts=2 et : */
/* EOF */
std::vector<Player*> get_players() {
return std::vector<Player*>(1, this->player);
}
+ Player *get_nearest_player (const Vector& pos);
Rectf get_active_region();