diff --git a/Images/X.png b/Images/X.png new file mode 100644 index 0000000..91f37d3 Binary files /dev/null and b/Images/X.png differ diff --git a/Images/image1.png b/Images/image1.png index 6e60bc2..22b23fa 100755 Binary files a/Images/image1.png and b/Images/image1.png differ diff --git a/Images/image10.png b/Images/image10.png index 7f8ab9b..b362383 100755 Binary files a/Images/image10.png and b/Images/image10.png differ diff --git a/Images/image11.png b/Images/image11.png index 8b67cb2..f025428 100755 Binary files a/Images/image11.png and b/Images/image11.png differ diff --git a/Images/image12.png b/Images/image12.png index 05b0dc2..d21b64b 100755 Binary files a/Images/image12.png and b/Images/image12.png differ diff --git a/Images/image13.png b/Images/image13.png index 34998cf..d05a013 100755 Binary files a/Images/image13.png and b/Images/image13.png differ diff --git a/Images/image2.png b/Images/image2.png index 99542e7..9f4a8a2 100755 Binary files a/Images/image2.png and b/Images/image2.png differ diff --git a/Images/image6.png b/Images/image6.png index 3c32b36..dc5f6b9 100644 Binary files a/Images/image6.png and b/Images/image6.png differ diff --git a/Images/image7.png b/Images/image7.png index a6dc544..2d65c17 100755 Binary files a/Images/image7.png and b/Images/image7.png differ diff --git a/Images/image8.png b/Images/image8.png index f8ed88f..392f254 100755 Binary files a/Images/image8.png and b/Images/image8.png differ diff --git a/Images/image9.png b/Images/image9.png index 909059d..8d7b29e 100755 Binary files a/Images/image9.png and b/Images/image9.png differ diff --git a/Images/rejouer.png b/Images/rejouer.png new file mode 100644 index 0000000..d4742e5 Binary files /dev/null and b/Images/rejouer.png differ diff --git a/Makefile b/Makefile index 5500736..7218ab6 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,19 @@ CFLAGS= -Wall -c -lgraph LDFLAGS= -Wall -lgraph EXEC=menu -jeu: main.o images.o menu.o jeu.o cheat.o - $(CC) -o jeu main.o images.o menu.o jeu.o cheat.o $(LDFLAGS) +jeu: main.o images.o menu.o jeu.o cheat.o rejouer.o + $(CC) -o jeu main.o images.o menu.o jeu.o cheat.o rejouer.o $(LDFLAGS) main.o: main.c images.h menu.h main.h $(CC) main.c $(CFLAGS) images.o: images.c images.h jeu.h $(CC) images.c $(CFLAGS) menu.o: menu.c menu.h $(CC) menu.c $(CFLAGS) -jeu.o: jeu.c jeu.h images.h cheat.h +jeu.o: jeu.c jeu.h images.h cheat.h rejouer.h $(CC) jeu.c $(CFLAGS) cheat.o: cheat.c cheat.h $(CC) cheat.c $(CFLAGS) +rejouer.o: rejouer.c rejouer.h images.h menu.h + $(CC) rejouer.c $(CFLAGS) run: ./jeu \ No newline at end of file diff --git a/Rapport.odt b/Rapport.odt deleted file mode 100644 index b3e6203..0000000 Binary files a/Rapport.odt and /dev/null differ diff --git a/Rapport.pdf b/Rapport.pdf new file mode 100644 index 0000000..1efe7aa Binary files /dev/null and b/Rapport.pdf differ diff --git a/action.c b/action.c deleted file mode 100644 index cc03c64..0000000 --- a/action.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include -#include -#include "images.h" -#include "action.h" - -int main(void){ - tirage_aleatoire(); - return EXIT_SUCCESS; -} \ No newline at end of file diff --git a/action.h b/action.h deleted file mode 100644 index d5fd548..0000000 --- a/action.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef ACTION_H -#define ACTION_H - -int main(void); - -#endif \ No newline at end of file diff --git a/cheat.c b/cheat.c index d9236d7..11e888f 100644 --- a/cheat.c +++ b/cheat.c @@ -3,7 +3,7 @@ #include #include "cheat.h" -int cheat(int affichage[50],int tab[40], int sauv_pos[40]){ +int cheat(char affichage[50],int tab[40], int sauv_pos[80], int im_x, int im_y){ int x,n,pos_x,pos_y; int i, oui; while(n<1){ @@ -28,9 +28,9 @@ int cheat(int affichage[50],int tab[40], int sauv_pos[40]){ pos_y=1000; } oui=0; - for (i=0;i<40;i++){ - if (sauv_pos[i]==pos_x && sauv_pos[i+1]==pos_y){ - oui=1; + for (i=0;i<80;i=i+2){ + if ((sauv_pos[i]==pos_x && sauv_pos[i+1]==pos_y) || (im_x==pos_x && im_y==pos_y)){ + oui=1; } } diff --git a/cheat.h b/cheat.h index 43691eb..598a128 100644 --- a/cheat.h +++ b/cheat.h @@ -1,6 +1,6 @@ #ifndef CHEAT_H #define CHEAT_H -int cheat(int affichage[50],int tab[40], int sauv_pos[40]); +int cheat(char affichage[50],int tab[40], int sauv_pos[80], int im_x, int im_y); #endif \ No newline at end of file diff --git a/grillage.c b/grillage.c deleted file mode 100644 index 2200407..0000000 --- a/grillage.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -#include - -int graphique(int L,int H){ - InitialiserGraphique(); - ChoisirEcran(0); - CreerFenetre(150,150,L,H);/*recuperation de L et H via le reste du programme*/ - Touche(); - FermerGraphique(); - return EXIT_SUCCESS; -} \ No newline at end of file diff --git a/images.c b/images.c index 50b2ea9..751f50e 100644 --- a/images.c +++ b/images.c @@ -7,9 +7,8 @@ #include "jeu.h" int tirage_aleatoire(int nb_paires){ - InitialiserGraphique(); char tirage[50]; - int pos_x, pos_y, clic_x, clic_y, im_y, im_x; + int pos_x, pos_y; int i, j; int nb,score; int tab[40]; @@ -63,27 +62,5 @@ int tirage_aleatoire(int nb_paires){ i++; } } - - - /*for (i=0;i<19;i++){ - printf("%03d", i); - printf(" "); - } - printf("\n"); - for (j=0;j<4;j++){ - for (i=0;i<20;i++){ - printf("%03d", positions[i][j]); - printf(" "); - } - printf("\n"); - } - for (i=0;i<40;i++){ - printf("%d\n",tab[i]); - }*/ - score=jeu(positions, nb_paires,tab); - Touche(); - FermerGraphique(); - printf("\n"); - return EXIT_SUCCESS; } diff --git a/jeu.c b/jeu.c index 5bef88d..80c757d 100644 --- a/jeu.c +++ b/jeu.c @@ -6,76 +6,86 @@ #include "jeu.h" #include #include "cheat.h" +#include "rejouer.h" int jeu(int position[20][4], int nb_paires,int tab[40]){ - int score=0,score2,repet,test=0; + int score=0,score2,repet; int pos_x,pos_y,oui; - int i,j,g,l=0,n=0,x=0,stock_g_1,stock_g_2,sauv_pos[40]; + int i,j,g,l=0,n=0,x=0,stock_g_1,stock_g_2,sauv_pos[80]; int repet2, nb_images; - int clic_x,clic_y,im_y,im_x, im_x_1, im_x_2, im_y_1, im_y_2; - unsigned long temps, temps2,temps3=1; + int a; + int clic_x,clic_y,im_x, im_x_1, im_x_2, im_y, im_y_1, im_y_2,xpos,ypos; + unsigned long temps=0, temps2=Microsecondes(),temps3=1; char tempstab[50],affichage[50],scoretab[50]; - couleur c=CouleurParComposante(0,0,0); - temps2=Microsecondes(); - ChargerImage("./Images/score.png",760,250,0,0,224,63); - printf("Voici le nombre de paires: %d\n", nb_paires); + ChargerImage("./Images/score.png",760,200,0,0,224,63); nb_images=nb_paires*2; score=0; c=CouleurParComposante(255,255,255); ChoisirCouleurDessin(c); - RemplirRectangle(850,320,50,50); - snprintf(scoretab,50,"%d",score); + RemplirRectangle(850,270,50,50); + snprintf(scoretab,50,"%d",score); c=CouleurParComposante(0,0,0); ChoisirCouleurDessin(c); - EcrireTexte(865,360,scoretab,2); - - for (i=0;i<40;i++){ + EcrireTexte(865,310,scoretab,2); + ChargerImage("./Images/X.png",950,15,0,0,62,63); + for (i=0;i<80;i++){ sauv_pos[i]=0; } while(score=950 && xpos<=1002) && (ypos>=15 && ypos<=78)){ + FermerGraphique(); + return EXIT_SUCCESS; + } /*Détection des coordonées x et y du clic de la souris*/ for (pos_y=370;pos_y>=10;pos_y=pos_y-90){ if (clic_y>=pos_y){ @@ -120,7 +130,6 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){ } snprintf(affichage,50,"Images/image%d.png",g); ChargerImage(affichage,im_x,im_y,0,0,80,80); - printf("%s\n", affichage); repet++; } } @@ -151,7 +160,7 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){ for (pos_y=10;pos_y<=370;pos_y=pos_y+90){ for (pos_x=10;pos_x<=640;pos_x=pos_x+90){ oui=0; - for (i=0;i=760 && xpos<=986) && (ypos>=460 && ypos<=504)){ + a=rejouer(); + } + if((xpos>=950 && xpos<=1002) && (ypos>=15 && ypos<=78)){ + FermerGraphique(); + return EXIT_SUCCESS; + } + } + } FermerGraphique(); - return 1; + return EXIT_SUCCESS; } \ No newline at end of file diff --git a/main.c b/main.c index 0ad8fe3..aa13f1a 100644 --- a/main.c +++ b/main.c @@ -8,9 +8,8 @@ int main(void){ - int temps,coucou; + InitialiserGraphique(); + CreerFenetre(0,0,1024,576); int nb_paires=menu(); - char tableautemps[50]; tirage_aleatoire(nb_paires); - return EXIT_SUCCESS; } \ No newline at end of file diff --git a/menu.c b/menu.c index 29484a4..ea0db28 100644 --- a/menu.c +++ b/menu.c @@ -9,8 +9,6 @@ int menu(void){ int ypos; int i=10,j=3; char choix[50]; - InitialiserGraphique(); - CreerFenetre(0,0,1024,576); couleur c=CouleurParComposante(255,255,255); ChoisirCouleurDessin(c); ChargerImage("Images/background.png",0,0,0,0,1024,576); diff --git a/rejouer.c b/rejouer.c new file mode 100644 index 0000000..403fd3f --- /dev/null +++ b/rejouer.c @@ -0,0 +1,12 @@ +#include +#include +#include +#include "images.h" +#include "menu.h" +#include "rejouer.h" + +int rejouer(void){ + int temps,coucou; + int nb_paires=menu(); + tirage_aleatoire(nb_paires); +} \ No newline at end of file diff --git a/rejouer.h b/rejouer.h new file mode 100644 index 0000000..01b5443 --- /dev/null +++ b/rejouer.h @@ -0,0 +1,6 @@ +#ifndef REJOUER_H +#define REJOUER_H + +int rejouer(void); + +#endif \ No newline at end of file diff --git a/temps.c b/temps.c deleted file mode 100644 index 73b5072..0000000 --- a/temps.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include -#include -#include "temps.h" -//faire une boucle tant que le jeu n'est pas fini -//affichage de texte pour afficher le timer -int main(void){ - char tab[50]; - InitialiserGraphique(); - CreerFenetre(0,0,1024,576); - couleur c=CouleurParComposante(0,0,0); - ChoisirCouleurDessin(c); - unsigned long temps; - unsigned long temps2; - temps=Microsecondes(); - while (1){ - temps2=(Microsecondes()-temps)/1000000; - snprintf(tab,50,"%ld secondes ecoulees",temps2); - c=CouleurParComposante(0,0,0); - ChoisirCouleurDessin(c); - RemplirRectangle(863,83,120,20); - c=CouleurParComposante(255,255,255); - ChoisirCouleurDessin(c); - EcrireTexte(867,100,tab,0); - if(SourisCliquee()){ - printf("x %d y %d",_X,_Y); - } - } - FermerGraphique(); - return EXIT_SUCCESS; -} \ No newline at end of file diff --git a/temps.h b/temps.h deleted file mode 100644 index 70c1b0b..0000000 --- a/temps.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef TEMPS_H -#define TEMPS_H - -int timer(void); - -#endif \ No newline at end of file