diff --git a/includes/Safari/PlateauSafari.hpp b/includes/Safari/PlateauSafari.hpp index 767defe..5b22ff2 100644 --- a/includes/Safari/PlateauSafari.hpp +++ b/includes/Safari/PlateauSafari.hpp @@ -9,4 +9,7 @@ public: // Initialise le plateau du Safari void initialiserPlateau() override; + + // Fonction pour afficher le plateau vers une sortie + void afficherPlateau(std::ostream &, const bool debug = false) const override; }; diff --git a/includes/Safari/Safari.hpp b/includes/Safari/Safari.hpp index 1ff0af4..9eae96c 100644 --- a/includes/Safari/Safari.hpp +++ b/includes/Safari/Safari.hpp @@ -14,9 +14,33 @@ class Safari : private Jeu { const Joueur &joueur2; const Joueur *joueur3; + // Etape du jeu, pour savoir où on en est + enum Etape { + ChoixJ1 = 0, + ChoixJ2, + ChoixJ3, + EnJeu, + Fini, + }; + + // Où l'on se trouve dans le jeu, à quelle étape nous sommes + enum Etape etape; + // Barrières std::vector barrieres; + // Permet de transformer une Piece en PieceSafari + const PieceSafari *getPiece(const int x, const int y) const; + + // Position curseur + const std::pair getPosition() const override; + + // Change de joueur courant + void changerJoueurCourant(); + + // Assignie un animal au joueur courant + void choixAnimal(const PieceSafari::Categorie animal); + public: Safari(Joueur &joueur1, Joueur &joueur2, Joueur *joueur3 = nullptr); // constructor @@ -27,10 +51,4 @@ public: // Fonction d'évènement void event(const int x, const int y) override; - - // Position curseur - const std::pair getPosition() const override; - - // Fonction d'initialisation du jeu - void choixAnimal(const PieceSafari::Categorie animal); }; diff --git a/src/Safari/PlateauSafari.cpp b/src/Safari/PlateauSafari.cpp index 9285d20..3a92272 100644 --- a/src/Safari/PlateauSafari.cpp +++ b/src/Safari/PlateauSafari.cpp @@ -1,9 +1,63 @@ #include "../../includes/Safari/PlateauSafari.hpp" +#include "../../includes/Ecran.hpp" PlateauSafari::PlateauSafari() : Plateau(8) {} PlateauSafari::~PlateauSafari() {} void PlateauSafari::initialiserPlateau() { - // TODO + // Au début, le plateau est vide +} + +void PlateauSafari::afficherPlateau(std::ostream &out, const bool d) const { + const float tailleCellule = static_cast(Ecran::largeur()) / taille; + + // Cellule + sf::RectangleShape cell(sf::Vector2f(tailleCellule, tailleCellule)); + + // Couleurs + sf::Color jaune = sf::Color(255, 200, 40); + sf::Color marron = sf::Color(155, 60, 40); + + for (int i = 0; i < taille; i++) { + for (int j = 0; j < taille; j++) { + const float x = i * tailleCellule; + const float y = j * tailleCellule; + + // Position de la cellule et de la pièce + cell.setPosition(x, y); + if (d) { + out << "(" << x << ", " << y; + } + + // Alternation des couleurs + if ((i + j) % 2 == 0) { + cell.setFillColor(jaune); + if (d) { + out << ", J), "; + } + } else { + cell.setFillColor(marron); + if (d) { + out << ", M), "; + } + } + + // Dessine la cellule + Ecran::window.draw(cell); + + // Dessine la piece + // TODO + } + if (d) { + out << "\n"; + } + } + + // Dessine les mur + // TODO + + if (d) { + out << "---\n"; + } }