From fe7fdd43d5cd8b5cfb1ee66c82c89d52b704c8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Thu, 7 Apr 2016 01:21:18 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20de=20l'ordre=20de=20profond?= =?UTF-8?q?eur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/object.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) 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(); }