From 3582844e5c6ab6c8737b2b2f55439389206f5e27 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 6 Jan 2024 19:41:44 +0100 Subject: [PATCH] fixes --- src/Dames/Dames.cpp | 2 +- src/Plateau.cpp | 7 ++++--- src/Safari/Safari.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Dames/Dames.cpp b/src/Dames/Dames.cpp index e915eb8..08d7aad 100644 --- a/src/Dames/Dames.cpp +++ b/src/Dames/Dames.cpp @@ -33,7 +33,7 @@ void Dames::play() { void Dames::event(const int, const int) {} const std::pair Dames::getPosition() const { - if (posCurseur.first > plateau.getTaille() - 1) { + if (posCurseur.second > plateau.getTaille() - 1) { std::cerr << "Position inconnu du plateau.\n"; return std::make_pair(-1, -1); } diff --git a/src/Plateau.cpp b/src/Plateau.cpp index 414fede..539246c 100644 --- a/src/Plateau.cpp +++ b/src/Plateau.cpp @@ -119,10 +119,11 @@ Piece *Plateau::getPiece(const int x, const int y) const { const std::pair Plateau::trouveCoordonnees(const int x, const int y) const { - const float tailleCellule = static_cast(Ecran::largeur()) / taille; + const float tailleCelluleX = static_cast(Ecran::largeur()) / taille; + const float tailleCelluleY = static_cast(Ecran::hauteur()) / taille; - return std::make_pair(static_cast(x / tailleCellule), - static_cast(y / tailleCellule)); + return std::make_pair(static_cast(x / tailleCelluleX), + static_cast(y / tailleCelluleY)); } int Plateau::getTaille() const { diff --git a/src/Safari/Safari.cpp b/src/Safari/Safari.cpp index 41a0efd..cc817cc 100644 --- a/src/Safari/Safari.cpp +++ b/src/Safari/Safari.cpp @@ -34,7 +34,7 @@ void Safari::play() { void Safari::event(const int, const int) {} const std::pair Safari::getPosition() const { - if (posCurseur.first > plateau.getTaille() - 1) { + if (posCurseur.second > plateau.getTaille() - 1) { std::cerr << "Position inconnu du plateau.\n"; return std::make_pair(-1, -1); }