From 2e1f7afdc35eec78efbdf775051ee2edae6d8f2d Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 7 Jan 2024 14:38:49 +0100 Subject: [PATCH] affichage barriere & fix selection --- src/Safari/PlateauSafari.cpp | 16 +++++++--------- src/Safari/Safari.cpp | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Safari/PlateauSafari.cpp b/src/Safari/PlateauSafari.cpp index 7ddac53..974e3a2 100644 --- a/src/Safari/PlateauSafari.cpp +++ b/src/Safari/PlateauSafari.cpp @@ -116,22 +116,20 @@ void PlateauSafari::afficherPlateau(std::ostream &out, const bool d) const { Position pos1 = it->getPos(); Position pos2 = it->getPos2(); - float x, y; - const int decalage = 10; - + const float decalage = 5; // Verticale if (pos1.first == pos2.first) { - x = pos1.first; - y = std::max(pos1.second, pos2.second) - decalage; - barriereV.setPosition(x * tailleCellule, y * tailleCellule); + const int x = pos1.first; + const int y = std::max(pos1.second, pos2.second); + barriereV.setPosition(x * tailleCellule, y * tailleCellule - decalage); Ecran::window.draw(barriereV); } // Horizontale else { - x = std::max(pos1.first, pos2.first) - decalage; - y = pos1.second; - barriereH.setPosition(x * tailleCellule, y * tailleCellule); + const int x = std::max(pos1.first, pos2.first); + const int y = pos1.second; + barriereH.setPosition(x * tailleCellule - decalage, y * tailleCellule); Ecran::window.draw(barriereH); } } diff --git a/src/Safari/Safari.cpp b/src/Safari/Safari.cpp index a14dbb1..ea2a0ed 100644 --- a/src/Safari/Safari.cpp +++ b/src/Safari/Safari.cpp @@ -200,6 +200,7 @@ void Safari::event(const int x, const int y) { if (placeholder.first == -1) { // On place le placeholder plateau.setPlaceholderBarriere(posCurseur.first, posCurseur.second); + } else { // On vérifie que le second point est bien positionné // Et on place la barrière si possible @@ -216,7 +217,7 @@ void Safari::event(const int x, const int y) { } } - if (p != nullptr) { + if (!deplacerAnimal && p != nullptr) { // Vérifie que la pièce est à nous if (getPiece(posCurseur.first, posCurseur.second)->getCategory() == getPiece(joueurCourant->getPieces().at(0))->getCategory()) {