Correction du choix du thème et du tableau à 3 colones
This commit is contained in:
@@ -15,8 +15,8 @@ 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 = "themes/themeSea.txt";
|
||||
int codeConsole = 0;
|
||||
|
||||
@@ -90,15 +90,15 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
string emoteUp,
|
||||
emoteDown,
|
||||
iconJ1,
|
||||
iconJ2;
|
||||
emoteJ1,
|
||||
emoteJ2;
|
||||
|
||||
// Faire une fonction pour retenir le th<74>me s<>lectionn<6E> par le joueur!!!!
|
||||
|
||||
ouvrirFichier(monFlux, style);
|
||||
if (monFlux) {
|
||||
while (!monFlux.eof()) {
|
||||
monFlux >> emoteUp >> emoteDown >> ICONJ1 >> ICONJ2;
|
||||
monFlux >> emoteUp >> emoteDown >> emoteJ1 >> emoteJ2;
|
||||
}
|
||||
monFlux.close();
|
||||
cout << endl;
|
||||
@@ -109,10 +109,9 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
|
||||
}
|
||||
fermerFichier(monFlux);
|
||||
|
||||
grid[0][0] = ICONJ1;
|
||||
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 << "Joueur 1: " << emoteJ1 << " Joueur 2: " << emoteJ2 << endl << endl;
|
||||
|
||||
cout << " ";
|
||||
for (int i = 0; i < LARGTIC; i++) {
|
||||
cout << " " << i + 1 << " ";
|
||||
@@ -132,21 +131,32 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
cout << " ";
|
||||
}
|
||||
cout << " ";
|
||||
}
|
||||
cout << "|" << endl << " " << k + 1 << " ";
|
||||
|
||||
|
||||
for (int i = 0; i < LARGTIC; i++) {
|
||||
cout << "|" << " " << grid[k][i] << " ";
|
||||
|
||||
cout << "|" << " " ;
|
||||
if (grid[k][i] == "X") {
|
||||
cout << emoteJ1;
|
||||
}
|
||||
cout << " |" << endl << " ";
|
||||
else if (grid[k][i] == "O") {
|
||||
cout << emoteJ2;
|
||||
}
|
||||
else {
|
||||
cout << " ";
|
||||
}
|
||||
cout << " ";
|
||||
}
|
||||
cout << "|" << endl << " ";
|
||||
|
||||
for (int i = 0; i < LARGTIC; i++) {
|
||||
cout << "|";
|
||||
for (int j = 0; j < 3; j++) {
|
||||
cout << " ";
|
||||
}
|
||||
cout << " ";
|
||||
}
|
||||
cout << "|" << endl << " ";
|
||||
|
||||
@@ -189,19 +199,23 @@ void tourJoueur(string grid[][LARGTIC], int joueur) {
|
||||
verticale -= 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!!!!!
|
||||
cout << "\n\nVeuillez choisir une case vide.\n"
|
||||
<< "\n\nEntrez une coordonnee verticale : ";
|
||||
cin >> verticale;
|
||||
cout << "\nEntrez une coordonnee horizontale : ";
|
||||
cin >> horizontale;
|
||||
|
||||
verticale--;
|
||||
horizontale--;
|
||||
}
|
||||
|
||||
if (joueur == 1) {
|
||||
grid[verticale - 1][horizontale - 1] = ICONJ1;
|
||||
grid[verticale][horizontale] = iconJ1;
|
||||
}
|
||||
else {
|
||||
grid[verticale - 1][horizontale - 1] = ICONJ2;
|
||||
grid[verticale][horizontale] = iconJ2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,8 +329,8 @@ void tourOrdi(string grid[][LARGTIC]) {
|
||||
do {
|
||||
vertical = rand() % (3);
|
||||
horizontal = rand() % (3);
|
||||
} while (grid[vertical][horizontal] != " ");
|
||||
grid[vertical][horizontal] = ICONJ2;
|
||||
} while (grid[vertical][horizontal] != "");
|
||||
grid[vertical][horizontal] = iconJ2;
|
||||
afficherImageTableau(grid, style);
|
||||
}
|
||||
|
||||
@@ -342,7 +356,7 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) {
|
||||
}
|
||||
|
||||
//Changer le th<74>me
|
||||
void changerLeTheme() {
|
||||
void changerLeTheme(bool &theme) {
|
||||
string grid[LARGTIC][LARGTIC];
|
||||
system("cls");
|
||||
do {
|
||||
@@ -354,6 +368,9 @@ void changerLeTheme() {
|
||||
choix = toupper(_getche());
|
||||
cout << endl;
|
||||
|
||||
if (choix >= 'A' && choix <= 'D') {
|
||||
theme = true;
|
||||
}
|
||||
switch (choix) {
|
||||
case 'A':
|
||||
style = "themes/themeSea.txt";
|
||||
|
||||
@@ -35,4 +35,5 @@ void tourOrdi(std::string grid[][LARGTIC]);
|
||||
void jeuDeuxJoueurs(std::string grid[][LARGTIC]);
|
||||
|
||||
//Changer le th<74>me
|
||||
void changerLeTheme();
|
||||
void changerLeTheme(bool& theme);
|
||||
|
||||
|
||||
@@ -45,8 +45,7 @@ int main() {
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
changerLeTheme();
|
||||
theme = true;
|
||||
changerLeTheme(theme);
|
||||
break;
|
||||
|
||||
case 'Q':
|
||||
|
||||
Reference in New Issue
Block a user