ajout du fichier cheat.c pour triche

This commit is contained in:
morinl 2022-12-03 18:52:19 +01:00
parent 4db49b6ccb
commit 8a016d359b
4 changed files with 50 additions and 32 deletions

View File

@ -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

37
cheat.c Normal file
View File

@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <graph.h>
#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;
}

6
cheat.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef CHEAT_H
#define CHEAT_H
int cheat(int affichage[50],int tab[40]);
#endif

31
jeu.c
View File

@ -5,6 +5,7 @@
#include "images.h"
#include "jeu.h"
#include <unistd.h>
#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*/