diff --git a/Makefile b/Makefile index d2b9ec9..5500736 100644 --- a/Makefile +++ b/Makefile @@ -3,15 +3,17 @@ CFLAGS= -Wall -c -lgraph LDFLAGS= -Wall -lgraph EXEC=menu -jeu: main.o images.o menu.o jeu.o - $(CC) -o jeu main.o images.o menu.o jeu.o $(LDFLAGS) +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) 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 +jeu.o: jeu.c jeu.h images.h cheat.h $(CC) jeu.c $(CFLAGS) +cheat.o: cheat.c cheat.h + $(CC) cheat.c $(CFLAGS) run: ./jeu \ No newline at end of file diff --git a/cheat.c b/cheat.c new file mode 100644 index 0000000..1b45c1f --- /dev/null +++ b/cheat.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include "cheat.h" + +int cheat(int affichage[50],int tab[40]){ + int x,n,pos_x,pos_y; + while(n<1){ + x=0; + for (pos_y=10;pos_y<=370;pos_y=pos_y+90){ + for (pos_x=10;pos_x<=640;pos_x=pos_x+90){ + if (tab[x]==-1){ + pos_x=650; + pos_y=1000; + } + snprintf(affichage,50,"Images/image%d.png",(tab[x]+1)); + ChargerImage(affichage,pos_x,pos_y,0,0,80,80); + x++; + } + } + if(ToucheEnAttente() && Touche()==XK_t){ + x=0; + for (pos_y=10;pos_y<=370;pos_y=pos_y+90){ + for (pos_x=10;pos_x<=640;pos_x=pos_x+90){ + if (tab[x]==-1){ + pos_x=650; + pos_y=1000; + } + ChargerImage("Images/image0.png",pos_x,pos_y,0,0,80,80); + x++; + } + } + n=1; + } + } + return n; +} \ No newline at end of file diff --git a/cheat.h b/cheat.h new file mode 100644 index 0000000..4c0f509 --- /dev/null +++ b/cheat.h @@ -0,0 +1,6 @@ +#ifndef CHEAT_H +#define CHEAT_H + +int cheat(int affichage[50],int tab[40]); + +#endif \ No newline at end of file diff --git a/jeu.c b/jeu.c index 3864b80..0a41504 100644 --- a/jeu.c +++ b/jeu.c @@ -5,6 +5,7 @@ #include "images.h" #include "jeu.h" #include +#include "cheat.h" int jeu(int position[20][4], int nb_paires,int tab[40]){ int score=0,score2,repet,test=0; @@ -59,35 +60,7 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){ /*Triche*/ if(ToucheEnAttente() && Touche()==XK_t){ - n=0; - while(n<1){ - x=0; - for (pos_y=10;pos_y<=370;pos_y=pos_y+90){ - for (pos_x=10;pos_x<=640;pos_x=pos_x+90){ - if (tab[x]==-1){ - pos_x=650; - pos_y=1000; - } - snprintf(affichage,50,"Images/image%d.png",(tab[x]+1)); - ChargerImage(affichage,pos_x,pos_y,0,0,80,80); - x++; - } - } - if(ToucheEnAttente() && Touche()==XK_t){ - x=0; - for (pos_y=10;pos_y<=370;pos_y=pos_y+90){ - for (pos_x=10;pos_x<=640;pos_x=pos_x+90){ - if (tab[x]==-1){ - pos_x=650; - pos_y=1000; - } - ChargerImage("Images/image0.png",pos_x,pos_y,0,0,80,80); - x++; - } - } - n=1; - } - } + n=cheat(affichage,tab); } /*Clic de la souris*/