couleur cases plateau

This commit is contained in:
Mylloon 2024-01-08 22:54:18 +01:00
parent 8b080c62f9
commit d9d0596d74
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 13 additions and 6 deletions

View file

@ -7,6 +7,9 @@
class Plateau { class Plateau {
friend std::ostream &operator<<(std::ostream &, const Plateau &); friend std::ostream &operator<<(std::ostream &, const Plateau &);
// Couleurs des cases
sf::Color blanc, noir;
protected: protected:
// Tableau représentant le plateau de jeu // Tableau représentant le plateau de jeu
Piece ***plateau; Piece ***plateau;
@ -18,8 +21,10 @@ protected:
Piece *selection; Piece *selection;
public: public:
Plateau(const int taille); // constructor Plateau(const int taille,
virtual ~Plateau(); // destructor const sf::Color couleurCaseBlanche = sf::Color::White,
const sf::Color couleurCaseNoire = sf::Color::Black); // constructor
virtual ~Plateau(); // destructor
// Fonction pour afficher le plateau (selon le jeu) vers une sortie // Fonction pour afficher le plateau (selon le jeu) vers une sortie
virtual void afficherPlateau(std::ostream &, const bool debug = false) const; virtual void afficherPlateau(std::ostream &, const bool debug = false) const;

View file

@ -2,7 +2,8 @@
#include "../../includes/Dames/PieceDames.hpp" #include "../../includes/Dames/PieceDames.hpp"
PlateauDames::PlateauDames(Joueur &joueur1, Joueur &joueur2) PlateauDames::PlateauDames(Joueur &joueur1, Joueur &joueur2)
: Plateau(10), j1(&joueur1), j2(&joueur2) { : Plateau(10, sf::Color(255, 205, 160), sf::Color(210, 140, 70)),
j1(&joueur1), j2(&joueur2) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
if ((i % 2 == 0 && j % 2 == 1) || (i % 2 == 1 && j % 2 == 0)) { if ((i % 2 == 0 && j % 2 == 1) || (i % 2 == 1 && j % 2 == 0)) {

View file

@ -1,7 +1,8 @@
#include "../includes/Plateau.hpp" #include "../includes/Plateau.hpp"
#include "../includes/Ecran.hpp" #include "../includes/Ecran.hpp"
Plateau::Plateau(const int t) : plateau(new Piece **[t]), taille(t) { Plateau::Plateau(const int t, const sf::Color b, const sf::Color n)
: blanc(b), noir(n), plateau(new Piece **[t]), taille(t) {
// Création du plateau vide // Création du plateau vide
for (int i = 0; i < t; i++) { for (int i = 0; i < t; i++) {
plateau[i] = new Piece *[t]; plateau[i] = new Piece *[t];
@ -50,13 +51,13 @@ void Plateau::afficherPlateau(std::ostream &out, const bool d) const {
// Alternation des couleurs // Alternation des couleurs
if ((i + j) % 2 == 0) { if ((i + j) % 2 == 0) {
cell.setFillColor(sf::Color::White); cell.setFillColor(blanc);
piece.setOutlineColor(sf::Color::Black); piece.setOutlineColor(sf::Color::Black);
if (d) { if (d) {
out << ", B), "; out << ", B), ";
} }
} else { } else {
cell.setFillColor(sf::Color::Black); cell.setFillColor(noir);
piece.setOutlineColor(sf::Color::White); piece.setOutlineColor(sf::Color::White);
if (d) { if (d) {
out << ", N), "; out << ", N), ";