diff --git a/comportementJCJ.c b/comportementJCJ.c index f58cc61..0e47de5 100644 --- a/comportementJCJ.c +++ b/comportementJCJ.c @@ -10,7 +10,7 @@ #include "verificationblock.h" -void compJCJ(int taille){ +int compJCJ(int taille){ int fin = 0, tabx = 0, taby = 0, tour = 0, initi = 0, SourisX = 0, SourisY = 0, x = 50, y = 100, initialiser = 0; int maxX = 0, maxY = 0, joueurx1 = 0, joueury1 = 0, joueurx2 = 0, joueury2 = 0, placer = 1; int emplacementcooX1 = 0, emplacementcooX2 = 0, emplacementcooY1 = 0, emplacementcooY2 = 0; @@ -44,12 +44,6 @@ void compJCJ(int taille){ initialiser++; SourisX = 0; SourisY = 0; - for(tabx = 0; tabx < taille + 2; tabx++){ - for(taby = 0; taby < taille + 2; taby++){ - printf("%d", grille[tabx][taby]); - } - printf("\n"); - } Efface(); EcrireTexte(30, 40, "Joueur 2 choisissez l'emplacement de base du pion 2", 1); } @@ -68,13 +62,6 @@ void compJCJ(int taille){ } SourisX = 0; SourisY = 0; - for(tabx = 0; tabx < taille + 2; tabx++){ - for(taby = 0; taby < taille + 2; taby++){ - printf("%d", grille[tabx][taby]); - } - printf("\n"); - } - } } } @@ -92,8 +79,11 @@ void compJCJ(int taille){ SourisY = _Y; } VerifBlock1(SourisX, SourisY, maxX, maxY, taille, empperso); + if(grille[joueury1+1 != 0 && joueury1-1 != 0 && joueurx1+1 != 0 && joueurx1-1 != 0){ + printf("\n\nechec\n\n"); + } if(empperso[0] != 0){ - if(grille[empperso[1]][empperso[0]] == 0){ + if(grille[empperso[1]][empperso[0]] == 0 && (empperso[1] <= joueury1+1 && empperso[1] >= joueury1-1) && (empperso[0] <= joueurx1+1 && empperso[0] >= joueurx1-1)){ grille[joueury1][joueurx1] = 0; ChoisirCouleurDessin(CouleurParNom("white")); RemplirRectangle(emplacementcooX1, emplacementcooY1, 40, 40); @@ -163,7 +153,7 @@ void compJCJ(int taille){ } VerifBlock1(SourisX, SourisY, maxX, maxY, taille, empperso); if(empperso[0] != 0){ - if(grille[empperso[1]][empperso[0]] == 0){ + if(grille[empperso[1]][empperso[0]] == 0 && (empperso[1] <= joueury2+1 && empperso[1] >= joueury2-1) && (empperso[0] <= joueurx2+1 && empperso[0] >= joueurx2-1)){ grille[joueury2][joueurx2] = 0; ChoisirCouleurDessin(CouleurParNom("white")); RemplirRectangle(emplacementcooX2, emplacementcooY2, 40, 40); diff --git a/comportementJCJ.h b/comportementJCJ.h index c96db1e..52fb677 100644 --- a/comportementJCJ.h +++ b/comportementJCJ.h @@ -2,7 +2,7 @@ #define COMPORTEMENTJCJ_H -void compJCJ(int taille); +int compJCJ(int taille); #endif diff --git a/game b/game deleted file mode 100755 index 3b6329b..0000000 Binary files a/game and /dev/null differ diff --git a/jeu.c b/jeu.c index 8f58392..457ed48 100644 --- a/jeu.c +++ b/jeu.c @@ -4,13 +4,23 @@ #include "comportementJCJ.h" #include "comportementJCIA.h" -void Jeu(){ - int choix[2], taille = 0; +int Jeu(){ + int choix[2], taille = 0, victoire = 0; Menu(choix); taille = choix[1]; if(choix[0] == 1){ - compJCJ(taille); + victoire = compJCJ(taille); + if(victoire == 1){ + return 1; + }else if(victoire == 2){ + return 2; + } }else if (choix[0] == 2){ compJCIA(taille); + if(victoire == 1){ + return 1; + }else if(victoire == 3){ + return 3; + } } } diff --git a/jeu.h b/jeu.h index f27f0fa..5d25167 100644 --- a/jeu.h +++ b/jeu.h @@ -2,7 +2,7 @@ #define JEU_H -void GraphJeu(); +int GraphJeu(); #endif diff --git a/main.c b/main.c index 0085ac2..428f482 100644 --- a/main.c +++ b/main.c @@ -3,8 +3,9 @@ #include "jeu.h" int main (void){ + int victoire = 0; InitialiserGraphique(); CreerFenetre(50, 50, 700, 500); /* Initialise la fenetre puis lance le programme jeu.c qui lancera d'autre programme */ EffacerEcran(CouleurParNom("white")); - Jeu(); + victoire = Jeu(); }