From 05c4c8a08cbf9ffbe0409f4f43b27048ce4882a0 Mon Sep 17 00:00:00 2001 From: Lea Date: Wed, 26 Nov 2025 10:28:45 -0500 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20toutes=20les=20commandes=20de=20Ch?= =?UTF-8?q?anger=20le=20th=C3=A8me=20et=20correction=20du=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TicTacToe/0 | 2 +- TicTacToe/fonctions.cpp | 26 ++++++++++++++++---------- TicTacToe/fonctions.h | 3 ++- TicTacToe/main.cpp | 4 ++-- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/TicTacToe/0 b/TicTacToe/0 index 6fe9972..4588032 100644 --- a/TicTacToe/0 +++ b/TicTacToe/0 @@ -1 +1 @@ -Press any key to continue . . . +Appuyez sur une touche pour continuer... diff --git a/TicTacToe/fonctions.cpp b/TicTacToe/fonctions.cpp index d7cc3bc..f7fcde9 100644 --- a/TicTacToe/fonctions.cpp +++ b/TicTacToe/fonctions.cpp @@ -15,8 +15,9 @@ BUT : Fichier de fonctions Tic Tac Toe using namespace std; extern const int LARGTIC; - string ICONJ1 = { "X" }; - string ICONJ2 = { "O" }; + string ICONJ1 = "X"; + string ICONJ2 = "O"; + string style; int codeConsole = 0; fstream monFlux; @@ -96,13 +97,15 @@ void initTab(string grid[][LARGTIC]) { void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { SetConsoleOutputCP(CP_UTF8); string emoteUp, - emoteDown; + emoteDown, + iconJ1, + iconJ2; // Faire une fonction pour retenir le thème sélectionné par le joueur!!!! ouvrirFichier(monFlux, style); if (monFlux) { while (!monFlux.eof()) { - monFlux >> emoteUp >> emoteDown >> ICONJ1 >> ICONJ2; + monFlux >> emoteUp >> emoteDown >> iconJ1 >> iconJ2; } monFlux.close(); cout << endl; @@ -167,7 +170,7 @@ void tourJoueur(string grid[][LARGTIC], int joueur) { horizontale; cout << "\n\nTour du joueur " << joueur << endl; - afficherImageTableau(grid); + afficherImageTableau(grid, style); cout << "\n\nEntrez une coordonnee verticale : "; cin >> verticale; @@ -254,7 +257,7 @@ bool verifFinMatch(std::string grid[][LARGTIC]) { } void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) { - afficherImageTableau(grid); + afficherImageTableau(grid, style); if (nbJoueurs == 1) { if (gagnant == 1) { @@ -302,7 +305,7 @@ void tourOrdi(string grid[][LARGTIC]) { horizontal = rand() % (3); } while (grid[vertical][horizontal] != " "); grid[vertical][horizontal] = ICONJ2; - afficherImageTableau(grid); + afficherImageTableau(grid, style); } //2 joueurs @@ -331,7 +334,7 @@ void historiqueDesScores() { } //Changer le thème -void changerLeTheme(std::string &style) { +void changerLeTheme() { string grid[LARGTIC][LARGTIC] = {ICONJ1, ICONJ2}; system("cls"); cout << endl << "Changer le theme du jeu Tic Tac Toe" << endl @@ -342,10 +345,12 @@ void changerLeTheme(std::string &style) { choix = toupper(_getche()); cout << endl; - switch (choix) { + do { + switch (choix) { case 'A': style = "themes/themeSea.txt"; afficherImageTableau(grid, style); + system("PAUSE"); break; case 'B': @@ -368,5 +373,6 @@ void changerLeTheme(std::string &style) { default: cout << "\nChoisir une option valide. \n"; - } + } + } while (choix != 'Q'); } \ No newline at end of file diff --git a/TicTacToe/fonctions.h b/TicTacToe/fonctions.h index ab4cfc3..d260006 100644 --- a/TicTacToe/fonctions.h +++ b/TicTacToe/fonctions.h @@ -22,7 +22,8 @@ void afficherImageMenu(std::fstream& monFlux); //Général void initTab(std::string grid[][LARGTIC]); -void afficherImageTableau(std::string grid[][LARGTIC]); +void afficherImageTableau(std::string grid[][LARGTIC], std::string style); +void changerLeTheme(std::string& style); void tourJoueur(std::string grid[][LARGTIC], int joueur); //pour savoir quel icon utiliser bool verifFinMatch(std::string grid[][LARGTIC]); void afficherFinMatch(std::string grid[][LARGTIC], int gagnant, int nbJoueurs); diff --git a/TicTacToe/main.cpp b/TicTacToe/main.cpp index 93c3e34..a4da395 100644 --- a/TicTacToe/main.cpp +++ b/TicTacToe/main.cpp @@ -10,8 +10,8 @@ BUT : Main pour le jeu Tic Tac Toe #include "fonctions.h" using namespace std; -const string ICONJ1 = { "X" }; -const string ICONJ2 = { "O" }; +const string ICONJ1 = "X"; +const string ICONJ2 = "O"; int main() { srand(time(NULL));