Dessin par ordre de profondeur
This commit is contained in:
parent
9130adec55
commit
574a53ca90
|
@ -11,7 +11,7 @@ Block::Block() : Object() {
|
||||||
setMass(0.f);
|
setMass(0.f);
|
||||||
|
|
||||||
// déplacement de l'origine au centre du bloc
|
// 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() {}
|
Block::~Block() {}
|
||||||
|
@ -31,7 +31,6 @@ ObjectPtr Block::load(std::ifstream& file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Block::draw(Manager& manager) {
|
void Block::draw(Manager& manager) {
|
||||||
Object::draw(manager);
|
|
||||||
|
|
||||||
// utilisation de la texture
|
// utilisation de la texture
|
||||||
sprite.setTexture(
|
sprite.setTexture(
|
||||||
|
@ -49,6 +48,7 @@ void Block::draw(Manager& manager) {
|
||||||
|
|
||||||
sprite.setPosition(getPosition());
|
sprite.setPosition(getPosition());
|
||||||
manager.getWindow().draw(sprite);
|
manager.getWindow().draw(sprite);
|
||||||
|
Object::draw(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<sf::FloatRect> Block::getAABB() const {
|
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 {
|
bool ObjectCompare::operator()(ObjectPtr const &t1, ObjectPtr const &t2) const {
|
||||||
if (t1->getLayer() == t2->getLayer()) {
|
if (t1->getLayer() != t2->getLayer()) {
|
||||||
sf::Vector2f t1_pos = t1->getPosition();
|
return t1->getLayer() > t2->getLayer();
|
||||||
sf::Vector2f t2_pos = t2->getPosition();
|
|
||||||
|
|
||||||
return t1_pos.x > t2_pos.x || t1_pos.y < t2_pos.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 "block.hpp"
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
const unsigned int Player::TYPE_ID = 1;
|
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) {
|
void Player::draw(Manager& manager) {
|
||||||
Object::draw(manager);
|
|
||||||
|
|
||||||
// utilisation de la texture
|
// utilisation de la texture
|
||||||
sprite.setTexture(
|
sprite.setTexture(
|
||||||
manager.getResourceManager().getTexture("ball.png")
|
manager.getResourceManager().getTexture("ball.png")
|
||||||
|
@ -78,6 +75,7 @@ void Player::draw(Manager& manager) {
|
||||||
// déplacement du sprite à la position de la balle
|
// déplacement du sprite à la position de la balle
|
||||||
sprite.setPosition(getPosition());
|
sprite.setPosition(getPosition());
|
||||||
manager.getWindow().draw(sprite);
|
manager.getWindow().draw(sprite);
|
||||||
|
Object::draw(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::updatePosition(float delta){
|
void Player::updatePosition(float delta){
|
||||||
|
|
Loading…
Reference in New Issue