Dessin par ordre de profondeur
This commit is contained in:
parent
9130adec55
commit
574a53ca90
|
@ -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<sf::FloatRect> Block::getAABB() const {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include "block.hpp"
|
||||
#include "constants.hpp"
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
|
||||
const unsigned int Player::TYPE_ID = 1;
|
||||
|
||||
|
@ -61,8 +60,6 @@ sf::Vector2f Player::getForces(const Manager& manager, const std::vector<ObjectP
|
|||
}
|
||||
|
||||
void Player::draw(Manager& manager) {
|
||||
Object::draw(manager);
|
||||
|
||||
// utilisation de la texture
|
||||
sprite.setTexture(
|
||||
manager.getResourceManager().getTexture("ball.png")
|
||||
|
@ -73,11 +70,12 @@ void Player::draw(Manager& manager) {
|
|||
sprite.setColor(sf::Color(239, 83, 80));
|
||||
} else if (getPlayerNumber() == 1) {
|
||||
sprite.setColor(sf::Color(92, 107, 192));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// déplacement du sprite à la position de la balle
|
||||
sprite.setPosition(getPosition());
|
||||
manager.getWindow().draw(sprite);
|
||||
Object::draw(manager);
|
||||
}
|
||||
|
||||
void Player::updatePosition(float delta){
|
||||
|
|
Loading…
Reference in New Issue