diff --git a/comportementJCJ.c b/comportementJCJ.c index e5846ed..638cfd7 100644 --- a/comportementJCJ.c +++ b/comportementJCJ.c @@ -15,7 +15,7 @@ void compJCJ(int taille){ int maxX = 0, maxY = 0, joueurx1 = 0, joueury1 = 0, joueurx2 = 0, joueury2 = 0, placer = 1; int emplacementcooX1 = 0, emplacementcooX2 = 0, emplacementcooY1 = 0, emplacementcooY2 = 0; int grille[taille+2][taille+2]; - int empblock[4] = {0, 0, 0, 0}; + int empblock[4] = {0, 0, 0, 0}, empperso[4] = {0, 0, 0, 0}; maxX = DefMaxX(taille); maxY = DefMaxY(taille); for(tabx = 0; tabx < taille + 2; tabx++){ @@ -65,18 +65,37 @@ void compJCJ(int taille){ } } } + ChargerSprite("croix1.png"); + ChargerSprite("croix2.png"); while(fin == 0){ if(tour == 0){ Efface(); EcrireTexte(30, 40, "Tour du joueur 1", 2); SourisX = 0; - SourisY = 0;/* + SourisY = 0; while(placer == 1){ if(SourisCliquee()){ SourisX = _X; SourisY = _Y; } - }*/ + VerifBlock1(SourisX, SourisY, maxX, maxY, taille, empperso); + if(empperso[0] != 0){ + if(grille[empperso[1]][empperso[0]] == 0){ + grille[joueurx1][joueury1] = 0; + ChoisirCouleurDessin(CouleurParNom("white")); + RemplirRectangle(joueurx1, joueury1, 45, 45); + ChoisirCouleurDessin(CouleurParNom("black")); + joueurx1 = empperso[0]; + joueury1 = empperso[1]; + empperso[2] = coordonerX(SourisX); + empperso[3] = coordonerY(SourisY); + grille[empperso[0]][empperso[1]] = 1; + AfficherSprite(1, empperso[2], empperso[3]); + placer = 0; + } + } + } + empperso[0] = 0; placer = 1; tour++; }else if(tour == 1){ @@ -91,16 +110,16 @@ void compJCJ(int taille){ } VerifBlock1(SourisX, SourisY, maxX, maxY, taille, empblock); if(empblock[0] != 0){ - ChargerSprite("croix1.png"); - grille[empblock[0]][empblock[1]]; if(grille[empblock[1]][empblock[0]] == 0){ empblock[2] = coordonerX(SourisX); empblock[3] = coordonerY(SourisY); + grille[empblock[0]][empblock[1]] = 3; AfficherSprite(3, empblock[2], empblock[3]); placer = 0; } } } + empblock[0] = 0; placer = 1; tour++; }else if(tour == 2){ @@ -120,16 +139,16 @@ void compJCJ(int taille){ } VerifBlock1(SourisX, SourisY, maxX, maxY, taille, empblock); if(empblock[0] != 0){ - ChargerSprite("croix2.png"); - grille[empblock[0]][empblock[1]]; if(grille[empblock[1]][empblock[0]] == 0){ empblock[2] = coordonerX(SourisX); empblock[3] = coordonerY(SourisY); + grille[empblock[0]][empblock[1]] = 4; AfficherSprite(4, empblock[2], empblock[3]); placer = 0; } } } + empblock[0] = 0; placer = 1; tour = 0; }