diff --git a/includes/Ecran.hpp b/includes/Ecran.hpp index dc79f0a..ad9c54e 100644 --- a/includes/Ecran.hpp +++ b/includes/Ecran.hpp @@ -3,7 +3,10 @@ #include #include -struct Ecran { +class Ecran { + static const uint bottomTxtPadding = 20; + +public: // Fenêtre static sf::RenderWindow window; @@ -19,4 +22,14 @@ struct Ecran { * -> appellé à chaque fois que l'utilisateur fait clic gauche */ const std::function doOnLeftClick = { [](const int, const int) {}}) const; + + // Largeur fenêtre + static uint largeur() { + return window.getSize().x; + } + + // Hauteur fenêtre + static uint hauteur() { + return window.getSize().y - bottomTxtPadding; + } }; diff --git a/src/Ecran.cpp b/src/Ecran.cpp index 2ef6390..646dd27 100644 --- a/src/Ecran.cpp +++ b/src/Ecran.cpp @@ -4,7 +4,7 @@ sf::RenderWindow Ecran::window; Ecran::Ecran(const uint w, const uint h, const std::string n) { // Création de la fenêtre SFML - window.create(sf::VideoMode(w, h), n); + window.create(sf::VideoMode(w, h + bottomTxtPadding), n); } Ecran::~Ecran() {} diff --git a/src/Plateau.cpp b/src/Plateau.cpp index 775f84a..65a8a89 100644 --- a/src/Plateau.cpp +++ b/src/Plateau.cpp @@ -24,8 +24,7 @@ std::ostream &operator<<(std::ostream &out, const Plateau &data) { } void Plateau::afficherPlateau(std::ostream &out, const bool d) const { - const float tailleCellule = - static_cast(Ecran::window.getSize().x) / taille; + const float tailleCellule = static_cast(Ecran::largeur()) / taille; // Adapte la vue pour le redimensionnement const float tailleFenetre = taille * tailleCellule; diff --git a/src/main.cpp b/src/main.cpp index 7eb9f71..7961ba0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,15 +1,7 @@ -#include "../includes/Butin/PlateauButin.hpp" -#include "../includes/Dames/PlateauDames.hpp" +#include "../includes/Butin/Butin.hpp" +#include "../includes/Dames/Dames.hpp" #include "../includes/Ecran.hpp" -#include "../includes/Safari/PlateauSafari.hpp" - -void draw_debug(Plateau &p) { - p.afficherPlateau(std::cout, false); -} - -void click_debug(const int x, const int y) { - std::cout << "Clic souris @ (" << x << ", " << y << ")\n"; -} +#include "../includes/Safari/Safari.hpp" void help(char const *progName) { std::cout << "Menu d'aide de " << progName << "\n"; @@ -35,7 +27,6 @@ int main(int argc, char const *argv[]) { Joueur j1; std::string arg = argv[1]; - Plateau *p; if (arg.compare("help") == 0) { help(argv[0]); @@ -44,18 +35,23 @@ int main(int argc, char const *argv[]) { else if (arg.compare("butin") == 0) { Joueur j2; - p = new PlateauButin(); + + Butin(j1, j2); } else if (arg.compare("dames") == 0) { Joueur j2; - p = new PlateauDames(j1, j2); + + Dames(j1, j2); } else if (arg.compare("safari") == 0) { Joueur j2; - Joueur j3; // demander à l'utilisateur - p = new PlateauSafari(); + Joueur *j3 = nullptr; + // TODO: demander à l'utilisateur un 3e joueur + {} + + Safari(j1, j2, j3); } else { @@ -65,11 +61,6 @@ int main(int argc, char const *argv[]) { return EXIT_FAILURE; } - e.afficher(std::bind(&draw_debug, std::ref(*p)), click_debug); - - // Libère le plateau de la mémoire - delete p; - std::cout << "Merci d'avoir joué !" << std::endl; } else { // Interface graphique, menu de selection de jeu ?