diff --git a/src/block.cpp b/src/block.cpp index 96b741b..50e6854 100644 --- a/src/block.cpp +++ b/src/block.cpp @@ -11,7 +11,7 @@ Block::Block() : Object() { setMass(0.f); // déplacement de l'origine au centre du bloc - sprite.setOrigin(sf::Vector2f(Constants::GRID / 2, 46 - Constants::GRID / 2)); + sprite.setOrigin(sf::Vector2f(23, 23)); } Block::~Block() {} @@ -31,7 +31,6 @@ ObjectPtr Block::load(std::ifstream& file) { } void Block::draw(Manager& manager) { - Object::draw(manager); // utilisation de la texture sprite.setTexture( @@ -49,6 +48,7 @@ void Block::draw(Manager& manager) { sprite.setPosition(getPosition()); manager.getWindow().draw(sprite); + Object::draw(manager); } std::unique_ptr Block::getAABB() const { diff --git a/src/object.cpp b/src/object.cpp index b01147f..c4f5bc5 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -316,12 +316,16 @@ void Object::setLayer(int set_layer) { } bool ObjectCompare::operator()(ObjectPtr const &t1, ObjectPtr const &t2) const { - if (t1->getLayer() == t2->getLayer()) { - sf::Vector2f t1_pos = t1->getPosition(); - sf::Vector2f t2_pos = t2->getPosition(); - - return t1_pos.x > t2_pos.x || t1_pos.y < t2_pos.y; + if (t1->getLayer() != t2->getLayer()) { + return 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; } diff --git a/src/player.cpp b/src/player.cpp index 1b4009f..cae4678 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2,7 +2,6 @@ #include "block.hpp" #include "constants.hpp" #include -#include const unsigned int Player::TYPE_ID = 1; @@ -61,8 +60,6 @@ sf::Vector2f Player::getForces(const Manager& manager, const std::vector