From 95f075a9d1e6ca4dce99f451e3bb79073f75c973 Mon Sep 17 00:00:00 2001 From: Axel Date: Fri, 2 Dec 2022 21:36:06 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Ajout=20de=20l'affichage=20et=20de=20la=20t?= =?UTF-8?q?otalit=C3=A9=20du=20gameplay=20avant=20la=20s=C3=A9paration=20e?= =?UTF-8?q?n=20fichiers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- affichage.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 173 insertions(+), 18 deletions(-) diff --git a/affichage.c b/affichage.c index 19ce43f..208304e 100644 --- a/affichage.c +++ b/affichage.c @@ -1,63 +1,218 @@ #include +#include #include +#define GRILLE_X 5 +#define GRILLE_Y 4 -void DessinerGrille(int x_g, int y_g, int x_fen, int y_fen, int triche){ +int Trouvee(int* found, int carte){ + int i; + for (i=0;i<10;i++){ + if (found[i] == carte) return 1; + } + return 0; +} + +void DefinirCouleurs(couleur c[10]){ + //Insère les couleurs dans le tableau c pris en argument + c[0] = CouleurParNom("red"); + c[1] = CouleurParNom("blue"); + c[2] = CouleurParNom("green"); + c[3] = CouleurParNom("yellow"); + c[4] = CouleurParNom("pink"); + c[5] = CouleurParNom("brown"); + c[6] = CouleurParNom("grey"); + c[7] = CouleurParNom("light blue"); + c[8] = CouleurParNom("purple"); + c[9] = CouleurParNom("orange"); +} + +int ZoneRectangle(int upper_x, int upper_y, int lower_x, int lower_y){ + //upper_x et upper_y sont les coordonnées du point supérieur gauche du rectangle + //lower_x et lower_y sont les coordonnées du point inferieur droit du rectangle + //La fonction renvoie 1 si la souris est dans la zone et renvoie 0 si elle n'y est pas + SourisPosition(); + int pos_x = _X; + int pos_y = _Y; + if ((pos_x >= upper_x) && (pos_x <= lower_x) && (pos_y >= upper_y) && (pos_y <= lower_y)) + return 1; + else return 0; +} + + +void DessinerGrille(int x_g, int y_g, int x_fen, int y_fen, int triche, int* found, int tab[4][5]){ + // Dessine la grille des cartes en noir si le mode de triche est désactivé et dévoile les cartes si le mode triche est activé int i,j; - int tab[2][2] = {{1,2},{1,2}}; + couleur c[10]; int x = 0; int y = 0; int l_case = (x_fen-((10*x_g)+10))/x_g; int h_case = (y_fen-((10*y_g)+10))/y_g; + DefinirCouleurs(c); if (triche == 0){ + ChoisirCouleurDessin(CouleurParNom("black")); for(i=10;i Date: Fri, 2 Dec 2022 22:02:14 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Modularit=C3=A9=20de=20la=20taille=20de=20l?= =?UTF-8?q?a=20grille=20et=20condition=20de=20victoire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- affichage.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/affichage.c b/affichage.c index 208304e..da2d83e 100644 --- a/affichage.c +++ b/affichage.c @@ -1,7 +1,7 @@ #include #include #include -#define GRILLE_X 5 +#define GRILLE_X 4 #define GRILLE_Y 4 int Trouvee(int* found, int carte){ @@ -112,7 +112,7 @@ void GenererGrille(int x_grille, int y_grille, int tab[4][5]){ } coos[0] = rand()%x_grille; coos[1] = rand()%y_grille; - for (i=0;i<10;i++){ + for (i=0;i<(x_grille*y_grille)/2;i++){ for (j=0;j<2;j++){ while (1){ coos[0] = rand()%x_grille; @@ -129,6 +129,13 @@ void Triche(int* triche){ *triche = -(*triche); } +int Victoire(int* found, int x_grille, int y_grille){ + int i,j; + for (i=0;i<(x_grille*y_grille)/2;i++){ + if (found[i] == 0) return 0; + } + return 1; +} void InsereTableau(int val, int* tab){ @@ -142,7 +149,7 @@ void InsereTableau(int val, int* tab){ } int main(void){ - int tab[GRILLE_Y][GRILLE_X] = {{},{},{},{}}; + int tab[4][5] = {{},{},{},{}}; int o; int timerStop; int i,j; @@ -210,7 +217,10 @@ int main(void){ DessinerGrille(GRILLE_X,GRILLE_Y,1500,844,0,found,tab); } - + if (Victoire(found,GRILLE_X,GRILLE_Y)){ + printf("Victoire !\n"); + break; + } } FermerGraphique();