From 78bdfbd44a99983714f3acb43f5d6be5743800dc Mon Sep 17 00:00:00 2001 From: abraham Date: Tue, 19 Nov 2024 17:25:51 +0100 Subject: [PATCH] changement du comportementJCIA.c --- Makefile | 2 +- comportementJCIA.c | 45 ++++++++++++++++++++++----------------------- comportementJCIA.h | 2 +- comportementJCJ.c | 2 -- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index f50e866..35f317a 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ nbjoueur.o : nbjoueur.h comportementJCJ.o : comportementJCJ.h definirMaxXY.h initialisation.h coordoner.h effacehaut.h verificationblock.h -comportementJCIA.o : comportementJCIA.h +comportementJCIA.o : comportementJCIA.h definirMaxXY.h initialisation.h coordoner.h effacehaut.h verificationblock.h boutonJVJ.o : boutonJVJ.h diff --git a/comportementJCIA.c b/comportementJCIA.c index 4ad2f7e..d0a32f1 100644 --- a/comportementJCIA.c +++ b/comportementJCIA.c @@ -1,4 +1,6 @@ #include +#include +#include #include "definirMaxXY.h" @@ -8,8 +10,8 @@ #include "verificationblock.h" -int compJCJ(int taille){ - int fin = 0, tabx = 0, taby = 0, tour = 0, initi = 0, SourisX = 0, SourisY = 0, initialiser = 0; +int compJCIA(int taille){ + int fin = 0, tabx = 0, taby = 0, tour = 0, initi = 0, SourisX = 0, SourisY = 0, initialiser = 0, inialea = 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; int grille[taille+2][taille+2]; @@ -39,28 +41,25 @@ int compJCJ(int taille){ emplacementcooY1 = coordonerY(SourisY); AfficherSprite(1, emplacementcooX1, emplacementcooY1); grille[joueury1][joueurx1] = 1; + initialiser = 0; + initi++; + SourisX = 0; + SourisY = 0; + } + } + } + initialiser = 1; + ChargerSprite("pion2.png"); + while(initialiser == 1){ + emplacementcooX2 = rand() % maxX + 95; + emplacementcooY2 = rand() % maxY - 12; + joueurx2 = initialisationX(emplacementcooX2, maxX, taille); + joueury2 = initialisationY(emplacementcooY2, maxY, taille); + printf("%d, %d\n", joueurx2, joueury2); + if(grille[joueury2][joueurx2] == 0){ + AfficherSprite(2, emplacementcooX2, emplacementcooY2); + grille[joueury2][joueurx2] = 2; initialiser++; - SourisX = 0; - SourisY = 0; - Efface(); - EcrireTexte(30, 40, "Joueur 2 choisissez l'emplacement de base du pion 2", 1); - } - }else if (initialiser == 1){ - if(SourisX >= 50 && SourisX <= maxX && SourisY >= 100 && SourisY <= maxY){ - ChargerSprite("pion2.png"); - joueurx2 = initialisationX(SourisX, maxX, taille); - joueury2 = initialisationY(SourisY, maxY, taille); - if(grille[joueury2][joueurx2] != 1){ - emplacementcooX2 = coordonerX(SourisX); - emplacementcooY2 = coordonerY(SourisY); - AfficherSprite(2, emplacementcooX2, emplacementcooY2); - grille[joueury2][joueurx2] = 2; - initialiser++; - initi++; - } - SourisX = 0; - SourisY = 0; - } } } ChargerSprite("croix1.png"); diff --git a/comportementJCIA.h b/comportementJCIA.h index 8d47e13..4d6b77a 100644 --- a/comportementJCIA.h +++ b/comportementJCIA.h @@ -2,7 +2,7 @@ #define COMPORTEMENTJCIA_H -void compJCIA(int taille); +int compJCIA(int taille); #endif diff --git a/comportementJCJ.c b/comportementJCJ.c index 4ad2f7e..07b4e76 100644 --- a/comportementJCJ.c +++ b/comportementJCJ.c @@ -1,6 +1,5 @@ #include - #include "definirMaxXY.h" #include "initialisation.h" #include "coordoner.h" @@ -168,7 +167,6 @@ int compJCJ(int taille){ empperso[0] = 0; placer = 1; tour++; - }else if(tour == 3){ Efface(); EcrireTexte(30, 40, "Joueur 2 place le bloc", 2);