This commit is contained in:
Lea
2025-11-28 08:29:19 -05:00
4 changed files with 20 additions and 35 deletions

View File

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

View File

@@ -15,8 +15,8 @@ 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 = "themes/themeSea.txt"; string style = "themes/themeSea.txt";
int codeConsole = 0; int codeConsole = 0;
@@ -90,15 +90,15 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
SetConsoleOutputCP(CP_UTF8); SetConsoleOutputCP(CP_UTF8);
string emoteUp, string emoteUp,
emoteDown, emoteDown,
emoteJ1, iconJ1,
emoteJ2; 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 >> emoteJ1 >> emoteJ2; monFlux >> emoteUp >> emoteDown >> ICONJ1 >> ICONJ2;
} }
monFlux.close(); monFlux.close();
cout << endl; cout << endl;
@@ -109,9 +109,10 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
} }
fermerFichier(monFlux); fermerFichier(monFlux);
// Lignes de code pour faire afficher le Tic Tac Toe une fois que les symboles ont <20>t<EFBFBD> ajout<75>s grid[0][0] = ICONJ1;
cout << "Joueur 1: " << emoteJ1 << " Joueur 2: " << emoteJ2 << endl << endl; grid[0][1] = ICONJ2;
// Lignes de code pour faire afficher le Tic Tac Toe une fois que les symboles ont <20>t<EFBFBD> ajout<75>s
cout << " "; cout << " ";
for (int i = 0; i < LARGTIC; i++) { for (int i = 0; i < LARGTIC; i++) {
cout << " " << i + 1 << " "; cout << " " << i + 1 << " ";
@@ -131,23 +132,13 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
cout << " "; cout << " ";
} }
cout << " ";
} }
cout << "|" << endl << " " << k + 1 << " "; cout << "|" << endl << " " << k + 1 << " ";
for (int i = 0; i < LARGTIC; i++) { for (int i = 0; i < LARGTIC; i++) {
cout << "|" << " " ; cout << "|" << " " << grid[k][i] << " ";
if (grid[k][i] == "X") {
cout << emoteJ1;
}
else if (grid[k][i] == "O") {
cout << emoteJ2;
}
else {
cout << " ";
}
cout << " ";
} }
cout << " |" << endl << " "; cout << " |" << endl << " ";
@@ -156,7 +147,6 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
cout << " "; cout << " ";
} }
cout << " ";
} }
cout << "|" << endl << " "; cout << "|" << endl << " ";
@@ -199,23 +189,20 @@ void tourJoueur(string grid[][LARGTIC], int joueur) {
verticale -= 1; verticale -= 1;
horizontale -= 1; horizontale -= 1;
while (grid[verticale][horizontale] == iconJ1 || grid[verticale][horizontale] == iconJ2) { while (grid[verticale][horizontale] == ICONJ1 || grid[verticale][horizontale] == ICONJ2) {
// V<>RIFIER LE CIN D'ERREUR!!!!! // V<>RIFIER LE CIN D'ERREUR!!!!!
cout << "\n\nVeuillez choisir une case vide.\n" cout << "\n\nVeuillez choisir une case vide.\n"
<< "\n\nEntrez une coordonnee verticale : "; << "\n\nEntrez une coordonnee verticale : ";
cin >> verticale; cin >> verticale;
cout << "\nEntrez une coordonnee horizontale : "; cout << "\nEntrez une coordonnee horizontale : ";
cin >> horizontale; cin >> horizontale;
verticale--;
horizontale--;
} }
if (joueur == 1) { if (joueur == 1) {
grid[verticale][horizontale] = iconJ1; grid[verticale][horizontale] = ICONJ1;
} }
else { else {
grid[verticale][horizontale] = iconJ2; grid[verticale][horizontale] = ICONJ2;
} }
} }
@@ -330,7 +317,7 @@ void tourOrdi(string grid[][LARGTIC]) {
vertical = rand() % (3); vertical = rand() % (3);
horizontal = rand() % (3); horizontal = rand() % (3);
} while (grid[vertical][horizontal] != ""); } while (grid[vertical][horizontal] != "");
grid[vertical][horizontal] = iconJ2; grid[vertical][horizontal] = ICONJ2;
afficherImageTableau(grid, style); afficherImageTableau(grid, style);
} }
@@ -356,7 +343,7 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) {
} }
//Changer le th<74>me //Changer le th<74>me
void changerLeTheme(bool &theme) { void changerLeTheme() {
string grid[LARGTIC][LARGTIC]; string grid[LARGTIC][LARGTIC];
system("cls"); system("cls");
do { do {
@@ -368,9 +355,6 @@ void changerLeTheme(bool &theme) {
choix = toupper(_getche()); choix = toupper(_getche());
cout << endl; cout << endl;
if (choix >= 'A' && choix <= 'D') {
theme = true;
}
switch (choix) { switch (choix) {
case 'A': case 'A':
style = "themes/themeSea.txt"; style = "themes/themeSea.txt";

View File

@@ -35,5 +35,5 @@ void tourOrdi(std::string grid[][LARGTIC]);
void jeuDeuxJoueurs(std::string grid[][LARGTIC]); void jeuDeuxJoueurs(std::string grid[][LARGTIC]);
//Changer le th<74>me //Changer le th<74>me
void changerLeTheme(bool& theme); void changerLeTheme();

View File

@@ -45,7 +45,8 @@ int main() {
break; break;
case 'C': case 'C':
changerLeTheme(theme); changerLeTheme();
theme = true;
break; break;
case 'Q': case 'Q':