diff --git a/src/object.cpp b/src/object.cpp index c4f5bc5..cce9f0c 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -316,16 +316,9 @@ void Object::setLayer(int set_layer) { } bool ObjectCompare::operator()(ObjectPtr const &t1, ObjectPtr const &t2) const { - if (t1->getLayer() != t2->getLayer()) { - return t1->getLayer() > t2->getLayer(); - } - sf::Vector2f t1_pos = t1->getPosition(); sf::Vector2f t2_pos = t2->getPosition(); - if (t1_pos.y != t2_pos.y) { - return t1_pos.y < t2_pos.y; - } - - return t1_pos.x > t2_pos.x; + return t1_pos.x - t1_pos.y + t1->getLayer() > + t2_pos.x - t2_pos.y + t2->getLayer(); }