Ajout de toutes les commandes de Changer le thème et correction du code

This commit is contained in:
Lea
2025-11-26 10:28:45 -05:00
parent b8f22030c2
commit 05c4c8a08c
4 changed files with 21 additions and 14 deletions

View File

@@ -1 +1 @@
Press any key to continue . . . Appuyez sur une touche pour continuer...

View File

@@ -15,8 +15,9 @@ BUT : Fichier de fonctions Tic Tac Toe
using namespace std; using namespace std;
extern const int LARGTIC; extern const int LARGTIC;
string ICONJ1 = { "X" }; string ICONJ1 = "X";
string ICONJ2 = { "O" }; string ICONJ2 = "O";
string style;
int codeConsole = 0; int codeConsole = 0;
fstream monFlux; fstream monFlux;
@@ -96,13 +97,15 @@ void initTab(string grid[][LARGTIC]) {
void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
SetConsoleOutputCP(CP_UTF8); SetConsoleOutputCP(CP_UTF8);
string emoteUp, string emoteUp,
emoteDown; emoteDown,
iconJ1,
iconJ2;
// Faire une fonction pour retenir le th<74>me s<>lectionn<6E> par le joueur!!!! // Faire une fonction pour retenir le th<74>me s<>lectionn<6E> par le joueur!!!!
ouvrirFichier(monFlux, style); ouvrirFichier(monFlux, style);
if (monFlux) { if (monFlux) {
while (!monFlux.eof()) { while (!monFlux.eof()) {
monFlux >> emoteUp >> emoteDown >> ICONJ1 >> ICONJ2; monFlux >> emoteUp >> emoteDown >> iconJ1 >> iconJ2;
} }
monFlux.close(); monFlux.close();
cout << endl; cout << endl;
@@ -167,7 +170,7 @@ void tourJoueur(string grid[][LARGTIC], int joueur) {
horizontale; horizontale;
cout << "\n\nTour du joueur " << joueur << endl; cout << "\n\nTour du joueur " << joueur << endl;
afficherImageTableau(grid); afficherImageTableau(grid, style);
cout << "\n\nEntrez une coordonnee verticale : "; cout << "\n\nEntrez une coordonnee verticale : ";
cin >> verticale; cin >> verticale;
@@ -254,7 +257,7 @@ bool verifFinMatch(std::string grid[][LARGTIC]) {
} }
void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) { void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) {
afficherImageTableau(grid); afficherImageTableau(grid, style);
if (nbJoueurs == 1) { if (nbJoueurs == 1) {
if (gagnant == 1) { if (gagnant == 1) {
@@ -302,7 +305,7 @@ void tourOrdi(string grid[][LARGTIC]) {
horizontal = rand() % (3); horizontal = rand() % (3);
} while (grid[vertical][horizontal] != " "); } while (grid[vertical][horizontal] != " ");
grid[vertical][horizontal] = ICONJ2; grid[vertical][horizontal] = ICONJ2;
afficherImageTableau(grid); afficherImageTableau(grid, style);
} }
//2 joueurs //2 joueurs
@@ -331,7 +334,7 @@ void historiqueDesScores() {
} }
//Changer le th<74>me //Changer le th<74>me
void changerLeTheme(std::string &style) { void changerLeTheme() {
string grid[LARGTIC][LARGTIC] = {ICONJ1, ICONJ2}; string grid[LARGTIC][LARGTIC] = {ICONJ1, ICONJ2};
system("cls"); system("cls");
cout << endl << "Changer le theme du jeu Tic Tac Toe" << endl cout << endl << "Changer le theme du jeu Tic Tac Toe" << endl
@@ -342,10 +345,12 @@ void changerLeTheme(std::string &style) {
choix = toupper(_getche()); choix = toupper(_getche());
cout << endl; cout << endl;
do {
switch (choix) { switch (choix) {
case 'A': case 'A':
style = "themes/themeSea.txt"; style = "themes/themeSea.txt";
afficherImageTableau(grid, style); afficherImageTableau(grid, style);
system("PAUSE");
break; break;
case 'B': case 'B':
@@ -369,4 +374,5 @@ void changerLeTheme(std::string &style) {
default: default:
cout << "\nChoisir une option valide. \n"; cout << "\nChoisir une option valide. \n";
} }
} while (choix != 'Q');
} }

View File

@@ -22,7 +22,8 @@ void afficherImageMenu(std::fstream& monFlux);
//G<>n<EFBFBD>ral //G<>n<EFBFBD>ral
void initTab(std::string grid[][LARGTIC]); 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 void tourJoueur(std::string grid[][LARGTIC], int joueur); //pour savoir quel icon utiliser
bool verifFinMatch(std::string grid[][LARGTIC]); bool verifFinMatch(std::string grid[][LARGTIC]);
void afficherFinMatch(std::string grid[][LARGTIC], int gagnant, int nbJoueurs); void afficherFinMatch(std::string grid[][LARGTIC], int gagnant, int nbJoueurs);

View File

@@ -10,8 +10,8 @@ BUT : Main pour le jeu Tic Tac Toe
#include "fonctions.h" #include "fonctions.h"
using namespace std; using namespace std;
const string ICONJ1 = { "X" }; const string ICONJ1 = "X";
const string ICONJ2 = { "O" }; const string ICONJ2 = "O";
int main() { int main() {
srand(time(NULL)); srand(time(NULL));