From 76cd5c4e635b119ee4bb5710f3a51a0a46c08bb5 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 1 Dec 2023 20:21:54 +0100 Subject: [PATCH] fix resize --- src/Plateau.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Plateau.cpp b/src/Plateau.cpp index f1eb9e6..b006b47 100644 --- a/src/Plateau.cpp +++ b/src/Plateau.cpp @@ -41,15 +41,19 @@ void Plateau::initialiserPlateau(Joueur &j1, Joueur &j2) { } void Plateau::afficherPlateau(const bool d) { - float taille_cellule = static_cast(Ecran::window.getSize().x) / taille; + float tailleCellule = static_cast(Ecran::window.getSize().x) / taille; + + // Adapte la vue pour le redimensionnement + const float tailleFenetre = taille * tailleCellule; + Ecran::window.setView( + sf::View(sf::FloatRect(0, 0, tailleFenetre, tailleFenetre))); // Cellule - sf::RectangleShape cell(sf::Vector2f(taille_cellule, taille_cellule)); - + sf::RectangleShape cell(sf::Vector2f(tailleCellule, tailleCellule)); for (int i = 0; i < taille; i++) { for (int j = 0; j < taille; j++) { - float x = i * taille_cellule; - float y = j * taille_cellule; + float x = i * tailleCellule; + float y = j * tailleCellule; // Position de la cellule cell.setPosition(x, y);