Merge branch 'master' of dwarves.iut-fbleau.fr:morinl/SAE11_2021
BIN
Images/X.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 739 B |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 593 B |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 521 B |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 627 B |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 896 B |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 811 B |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 931 B |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 521 B |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 526 B |
BIN
Images/rejouer.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
8
Makefile
@ -3,17 +3,19 @@ CFLAGS= -Wall -c -lgraph
|
|||||||
LDFLAGS= -Wall -lgraph
|
LDFLAGS= -Wall -lgraph
|
||||||
EXEC=menu
|
EXEC=menu
|
||||||
|
|
||||||
jeu: main.o images.o menu.o jeu.o cheat.o
|
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 $(LDFLAGS)
|
$(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
|
main.o: main.c images.h menu.h main.h
|
||||||
$(CC) main.c $(CFLAGS)
|
$(CC) main.c $(CFLAGS)
|
||||||
images.o: images.c images.h jeu.h
|
images.o: images.c images.h jeu.h
|
||||||
$(CC) images.c $(CFLAGS)
|
$(CC) images.c $(CFLAGS)
|
||||||
menu.o: menu.c menu.h
|
menu.o: menu.c menu.h
|
||||||
$(CC) menu.c $(CFLAGS)
|
$(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)
|
$(CC) jeu.c $(CFLAGS)
|
||||||
cheat.o: cheat.c cheat.h
|
cheat.o: cheat.c cheat.h
|
||||||
$(CC) cheat.c $(CFLAGS)
|
$(CC) cheat.c $(CFLAGS)
|
||||||
|
rejouer.o: rejouer.c rejouer.h images.h menu.h
|
||||||
|
$(CC) rejouer.c $(CFLAGS)
|
||||||
run:
|
run:
|
||||||
./jeu
|
./jeu
|
BIN
Rapport.odt
BIN
Rapport.pdf
Normal file
11
action.c
@ -1,11 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <graph.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include "images.h"
|
|
||||||
#include "action.h"
|
|
||||||
|
|
||||||
int main(void){
|
|
||||||
tirage_aleatoire();
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
6
cheat.c
@ -3,7 +3,7 @@
|
|||||||
#include <graph.h>
|
#include <graph.h>
|
||||||
#include "cheat.h"
|
#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 x,n,pos_x,pos_y;
|
||||||
int i, oui;
|
int i, oui;
|
||||||
while(n<1){
|
while(n<1){
|
||||||
@ -28,8 +28,8 @@ int cheat(int affichage[50],int tab[40], int sauv_pos[40]){
|
|||||||
pos_y=1000;
|
pos_y=1000;
|
||||||
}
|
}
|
||||||
oui=0;
|
oui=0;
|
||||||
for (i=0;i<40;i++){
|
for (i=0;i<80;i=i+2){
|
||||||
if (sauv_pos[i]==pos_x && sauv_pos[i+1]==pos_y){
|
if ((sauv_pos[i]==pos_x && sauv_pos[i+1]==pos_y) || (im_x==pos_x && im_y==pos_y)){
|
||||||
oui=1;
|
oui=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
cheat.h
@ -1,6 +1,6 @@
|
|||||||
#ifndef CHEAT_H
|
#ifndef CHEAT_H
|
||||||
#define 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
|
#endif
|
12
grillage.c
@ -1,12 +0,0 @@
|
|||||||
#include<stdio.h>
|
|
||||||
#include<stdlib.h>
|
|
||||||
#include<graph.h>
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
25
images.c
@ -7,9 +7,8 @@
|
|||||||
#include "jeu.h"
|
#include "jeu.h"
|
||||||
|
|
||||||
int tirage_aleatoire(int nb_paires){
|
int tirage_aleatoire(int nb_paires){
|
||||||
InitialiserGraphique();
|
|
||||||
char tirage[50];
|
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 i, j;
|
||||||
int nb,score;
|
int nb,score;
|
||||||
int tab[40];
|
int tab[40];
|
||||||
@ -63,27 +62,5 @@ int tirage_aleatoire(int nb_paires){
|
|||||||
i++;
|
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);
|
score=jeu(positions, nb_paires,tab);
|
||||||
Touche();
|
|
||||||
FermerGraphique();
|
|
||||||
printf("\n");
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
82
jeu.c
@ -6,76 +6,86 @@
|
|||||||
#include "jeu.h"
|
#include "jeu.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "cheat.h"
|
#include "cheat.h"
|
||||||
|
#include "rejouer.h"
|
||||||
|
|
||||||
int jeu(int position[20][4], int nb_paires,int tab[40]){
|
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 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 repet2, nb_images;
|
||||||
int clic_x,clic_y,im_y,im_x, im_x_1, im_x_2, im_y_1, im_y_2;
|
int a;
|
||||||
unsigned long temps, temps2,temps3=1;
|
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];
|
char tempstab[50],affichage[50],scoretab[50];
|
||||||
|
|
||||||
couleur c=CouleurParComposante(0,0,0);
|
couleur c=CouleurParComposante(0,0,0);
|
||||||
temps2=Microsecondes();
|
ChargerImage("./Images/score.png",760,200,0,0,224,63);
|
||||||
ChargerImage("./Images/score.png",760,250,0,0,224,63);
|
|
||||||
printf("Voici le nombre de paires: %d\n", nb_paires);
|
|
||||||
nb_images=nb_paires*2;
|
nb_images=nb_paires*2;
|
||||||
score=0;
|
score=0;
|
||||||
c=CouleurParComposante(255,255,255);
|
c=CouleurParComposante(255,255,255);
|
||||||
ChoisirCouleurDessin(c);
|
ChoisirCouleurDessin(c);
|
||||||
RemplirRectangle(850,320,50,50);
|
RemplirRectangle(850,270,50,50);
|
||||||
snprintf(scoretab,50,"%d",score);
|
snprintf(scoretab,50,"%d",score);
|
||||||
c=CouleurParComposante(0,0,0);
|
c=CouleurParComposante(0,0,0);
|
||||||
ChoisirCouleurDessin(c);
|
ChoisirCouleurDessin(c);
|
||||||
EcrireTexte(865,360,scoretab,2);
|
EcrireTexte(865,310,scoretab,2);
|
||||||
|
ChargerImage("./Images/X.png",950,15,0,0,62,63);
|
||||||
for (i=0;i<40;i++){
|
for (i=0;i<80;i++){
|
||||||
sauv_pos[i]=0;
|
sauv_pos[i]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(score<nb_paires){
|
while(score<nb_paires){
|
||||||
|
|
||||||
temps=(Microsecondes()-temps2)/1000000;
|
temps=(Microsecondes()-temps2)/1000000;
|
||||||
if(temps!=temps3){
|
if(temps!=temps3){
|
||||||
snprintf(tempstab,50,"%ld secondes ecoulees",temps);
|
snprintf(tempstab,50,"%ld secondes ecoulees",temps);
|
||||||
c=CouleurParComposante(0,0,0);
|
c=CouleurParComposante(0,0,0);
|
||||||
ChoisirCouleurDessin(c);
|
ChoisirCouleurDessin(c);
|
||||||
RemplirRectangle(863,83,120,20);
|
RemplirRectangle(863,100,120,20);
|
||||||
c=CouleurParComposante(255,255,255);
|
c=CouleurParComposante(255,255,255);
|
||||||
ChoisirCouleurDessin(c);
|
ChoisirCouleurDessin(c);
|
||||||
EcrireTexte(867,100,tempstab,0);
|
EcrireTexte(867,117,tempstab,0);
|
||||||
}
|
}
|
||||||
temps3=temps;
|
temps3=temps;
|
||||||
repet=0;
|
repet=0;
|
||||||
/*comparer[0]="vide";
|
im_x=0;
|
||||||
comparer[1]="vide";*/
|
im_x_1=0;
|
||||||
|
im_x_2=0;
|
||||||
|
im_y=0;
|
||||||
|
im_y_1=0;
|
||||||
|
im_y_2=0;
|
||||||
while (repet<2){
|
while (repet<2){
|
||||||
|
xpos=0;
|
||||||
|
ypos=0;
|
||||||
temps=(Microsecondes()-temps2)/1000000;
|
temps=(Microsecondes()-temps2)/1000000;
|
||||||
if(temps!=temps3){
|
if(temps!=temps3){
|
||||||
snprintf(tempstab,50,"%ld secondes ecoulees",temps);
|
snprintf(tempstab,50,"%ld secondes ecoulees",temps);
|
||||||
c=CouleurParComposante(0,0,0);
|
c=CouleurParComposante(0,0,0);
|
||||||
ChoisirCouleurDessin(c);
|
ChoisirCouleurDessin(c);
|
||||||
RemplirRectangle(863,83,120,20);
|
RemplirRectangle(863,100,120,20);
|
||||||
c=CouleurParComposante(255,255,255);
|
c=CouleurParComposante(255,255,255);
|
||||||
ChoisirCouleurDessin(c);
|
ChoisirCouleurDessin(c);
|
||||||
EcrireTexte(867,100,tempstab,0);
|
EcrireTexte(867,117,tempstab,0);
|
||||||
}
|
}
|
||||||
temps3=temps;
|
temps3=temps;
|
||||||
|
|
||||||
/*Triche*/
|
/*Triche*/
|
||||||
if(ToucheEnAttente() && Touche()==XK_t){
|
if(ToucheEnAttente() && Touche()==XK_t){
|
||||||
n=cheat(affichage,tab, sauv_pos);
|
n=cheat(affichage,tab, sauv_pos, im_x, im_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Clic de la souris*/
|
/*Clic de la souris*/
|
||||||
if (SourisCliquee()){
|
if (SourisCliquee()==1){
|
||||||
clic_x=_X;
|
clic_x=_X;
|
||||||
clic_y=_Y;
|
clic_y=_Y;
|
||||||
|
xpos=_X;
|
||||||
|
ypos=_Y;
|
||||||
im_x=0;
|
im_x=0;
|
||||||
im_y=0;
|
im_y=0;
|
||||||
|
|
||||||
|
/*Pour fermer le jeu avec le bouton X*/
|
||||||
|
if((xpos>=950 && xpos<=1002) && (ypos>=15 && ypos<=78)){
|
||||||
|
FermerGraphique();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
/*Détection des coordonées x et y du clic de la souris*/
|
/*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){
|
for (pos_y=370;pos_y>=10;pos_y=pos_y-90){
|
||||||
if (clic_y>=pos_y){
|
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);
|
snprintf(affichage,50,"Images/image%d.png",g);
|
||||||
ChargerImage(affichage,im_x,im_y,0,0,80,80);
|
ChargerImage(affichage,im_x,im_y,0,0,80,80);
|
||||||
printf("%s\n", affichage);
|
|
||||||
repet++;
|
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_y=10;pos_y<=370;pos_y=pos_y+90){
|
||||||
for (pos_x=10;pos_x<=640;pos_x=pos_x+90){
|
for (pos_x=10;pos_x<=640;pos_x=pos_x+90){
|
||||||
oui=0;
|
oui=0;
|
||||||
for (i=0;i<l;i++){
|
for (i=0;i<l;i=i+2){
|
||||||
if (sauv_pos[i]==pos_x && sauv_pos[i+1]==pos_y){
|
if (sauv_pos[i]==pos_x && sauv_pos[i+1]==pos_y){
|
||||||
oui=1;
|
oui=1;
|
||||||
}
|
}
|
||||||
@ -171,16 +180,29 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){
|
|||||||
if(score2!=score){
|
if(score2!=score){
|
||||||
c=CouleurParComposante(255,255,255);
|
c=CouleurParComposante(255,255,255);
|
||||||
ChoisirCouleurDessin(c);
|
ChoisirCouleurDessin(c);
|
||||||
RemplirRectangle(850,320,50,50);
|
RemplirRectangle(850,270,50,50);
|
||||||
snprintf(scoretab,50,"%d",score);
|
snprintf(scoretab,50,"%d",score);
|
||||||
c=CouleurParComposante(0,0,0);
|
c=CouleurParComposante(0,0,0);
|
||||||
ChoisirCouleurDessin(c);
|
ChoisirCouleurDessin(c);
|
||||||
EcrireTexte(865,360,scoretab,2);
|
EcrireTexte(865,310,scoretab,2);
|
||||||
}
|
}
|
||||||
score2=score;
|
score2=score;
|
||||||
}
|
}
|
||||||
ChargerImage("./Images/FIN.png",300,460,0,0,399,87);
|
ChargerImage("./Images/FIN.png",250,460,0,0,399,87);
|
||||||
Touche();
|
ChargerImage("./Images/rejouer.png",760,460,0,0,226,44);
|
||||||
FermerGraphique();
|
while(1){
|
||||||
return 1;
|
if(SourisCliquee()==1){
|
||||||
|
xpos=_X;
|
||||||
|
ypos=_Y;
|
||||||
|
if((xpos>=760 && xpos<=986) && (ypos>=460 && ypos<=504)){
|
||||||
|
a=rejouer();
|
||||||
|
}
|
||||||
|
if((xpos>=950 && xpos<=1002) && (ypos>=15 && ypos<=78)){
|
||||||
|
FermerGraphique();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FermerGraphique();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
5
main.c
@ -8,9 +8,8 @@
|
|||||||
|
|
||||||
|
|
||||||
int main(void){
|
int main(void){
|
||||||
int temps,coucou;
|
InitialiserGraphique();
|
||||||
|
CreerFenetre(0,0,1024,576);
|
||||||
int nb_paires=menu();
|
int nb_paires=menu();
|
||||||
char tableautemps[50];
|
|
||||||
tirage_aleatoire(nb_paires);
|
tirage_aleatoire(nb_paires);
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
2
menu.c
@ -9,8 +9,6 @@ int menu(void){
|
|||||||
int ypos;
|
int ypos;
|
||||||
int i=10,j=3;
|
int i=10,j=3;
|
||||||
char choix[50];
|
char choix[50];
|
||||||
InitialiserGraphique();
|
|
||||||
CreerFenetre(0,0,1024,576);
|
|
||||||
couleur c=CouleurParComposante(255,255,255);
|
couleur c=CouleurParComposante(255,255,255);
|
||||||
ChoisirCouleurDessin(c);
|
ChoisirCouleurDessin(c);
|
||||||
ChargerImage("Images/background.png",0,0,0,0,1024,576);
|
ChargerImage("Images/background.png",0,0,0,0,1024,576);
|
||||||
|
12
rejouer.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include<stdio.h>
|
||||||
|
#include<stdlib.h>
|
||||||
|
#include<graph.h>
|
||||||
|
#include "images.h"
|
||||||
|
#include "menu.h"
|
||||||
|
#include "rejouer.h"
|
||||||
|
|
||||||
|
int rejouer(void){
|
||||||
|
int temps,coucou;
|
||||||
|
int nb_paires=menu();
|
||||||
|
tirage_aleatoire(nb_paires);
|
||||||
|
}
|
6
rejouer.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef REJOUER_H
|
||||||
|
#define REJOUER_H
|
||||||
|
|
||||||
|
int rejouer(void);
|
||||||
|
|
||||||
|
#endif
|
32
temps.c
@ -1,32 +0,0 @@
|
|||||||
#include<stdio.h>
|
|
||||||
#include<stdlib.h>
|
|
||||||
#include<graph.h>
|
|
||||||
#include<math.h>
|
|
||||||
#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;
|
|
||||||
}
|
|