Travail du 07/12/22
This commit is contained in:
parent
6d1d07ae52
commit
3a156893f9
41
affichage.c
41
affichage.c
@ -2,8 +2,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
#define GRILLE_X 4
|
||||
#define GRILLE_Y 4
|
||||
|
||||
int Trouvee(int* found, int carte){
|
||||
int i;
|
||||
@ -149,10 +147,13 @@ void InsereTableau(int val, int* tab){
|
||||
}
|
||||
}
|
||||
|
||||
int essay(void){
|
||||
int essay(int grille_x){
|
||||
char afficher_temps[20];
|
||||
int tab[4][5] = {{},{},{},{}};
|
||||
int o;
|
||||
int timerStop;
|
||||
unsigned long temps_microsec = Microsecondes();
|
||||
unsigned long temps_ecoule = 0;
|
||||
unsigned long temps_ancien = -1;
|
||||
int i,j;
|
||||
int x=1;
|
||||
int temps;
|
||||
@ -161,24 +162,32 @@ int essay(void){
|
||||
int found[10] = {};
|
||||
int carte_1[3] = {0,-1,-1};
|
||||
int carte_2[3] = {0,-1,-1};
|
||||
GenererGrille(GRILLE_Y, GRILLE_X, tab);
|
||||
GenererGrille(4, grille_x, tab);
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(10,10,1500,844);
|
||||
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
||||
DessinerGrille(GRILLE_X,GRILLE_Y,1500,844,0,found,tab);
|
||||
while(1){
|
||||
timer();
|
||||
DessinerGrille(grille_x,4,1500,844,0,found,tab);
|
||||
while(1){
|
||||
if (x==1){
|
||||
timer(&temps_ecoule, temps_microsec);
|
||||
}
|
||||
if (temps_ecoule = temps_ancien+1){
|
||||
temps_ancien = temps_ecoule;
|
||||
ChoisirCouleurDessin(CouleurParNom("black"));
|
||||
RemplirRectangle(675,25,160,30);
|
||||
ChoisirCouleurDessin(CouleurParNom("white"));
|
||||
sprintf(afficher_temps,"Time : %03ds",temps_ecoule);
|
||||
EcrireTexte(700,50,afficher_temps,1);
|
||||
}
|
||||
if (ToucheEnAttente()){
|
||||
touche = Touche();
|
||||
if (touche == XK_t){
|
||||
Triche(&x);
|
||||
if (x==-1){
|
||||
DessinerGrille(GRILLE_X,GRILLE_Y,1500,844,1,found,tab);
|
||||
timerStop = 1;
|
||||
DessinerGrille(grille_x,4,1500,844,1,found,tab);
|
||||
}
|
||||
else{
|
||||
DessinerGrille(GRILLE_X,GRILLE_Y,1500,844,0,found,tab);
|
||||
timerStop = 0;
|
||||
DessinerGrille(grille_x,4,1500,844,0,found,tab);
|
||||
}
|
||||
}
|
||||
if (touche == XK_space)
|
||||
@ -189,13 +198,13 @@ int essay(void){
|
||||
if (x==1){
|
||||
|
||||
if (carte_1[0] == 0){
|
||||
Jeu(GRILLE_X,GRILLE_Y,1500,844,carte_1,tab);
|
||||
Jeu(grille_x,4,1500,844,carte_1,tab);
|
||||
if (Trouvee(found,carte_1[0])){
|
||||
carte_1[0] = 0;
|
||||
}
|
||||
}
|
||||
else if (carte_2[0] == 0){
|
||||
Jeu(GRILLE_X,GRILLE_Y,1500,844,carte_2,tab);
|
||||
Jeu(grille_x,4,1500,844,carte_2,tab);
|
||||
if (carte_1[1] == carte_2[1] && carte_1[2] == carte_2[2]) carte_2[0] = 0;
|
||||
if (Trouvee(found,carte_2[0])) carte_2[0] = 0;
|
||||
}
|
||||
@ -216,10 +225,10 @@ int essay(void){
|
||||
while (temps < retourne_time){
|
||||
temps = Microsecondes();
|
||||
}
|
||||
DessinerGrille(GRILLE_X,GRILLE_Y,1500,844,0,found,tab);
|
||||
DessinerGrille(grille_x,4,1500,844,0,found,tab);
|
||||
|
||||
}
|
||||
if (Victoire(found,GRILLE_X,GRILLE_Y)){
|
||||
if (Victoire(found,grille_x,4)){
|
||||
printf("Victoire !\n");
|
||||
break;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ int Victoire(int* found, int x_grille, int y_grille);
|
||||
|
||||
void InsereTableau(int val, int* tab);
|
||||
|
||||
int essay(void);
|
||||
int essay(int grille_x);
|
||||
|
||||
#endif /* AFFICHAGE_H */
|
||||
|
||||
|
30
menu_v2.c
30
menu_v2.c
@ -78,14 +78,16 @@ int menu_principal(void){
|
||||
y=_Y;
|
||||
|
||||
if((x>68) && (x<488) && (y>266) && (y<696)){
|
||||
EffacerEcran(CouleurParNom("grey"));
|
||||
FermerGraphique();
|
||||
essay(3);
|
||||
}
|
||||
if((x>537) && (x<958) && (y>266) && (y<696)){
|
||||
EffacerEcran(CouleurParNom("white"));
|
||||
essay();
|
||||
FermerGraphique();
|
||||
essay(4);
|
||||
}
|
||||
if((x>1007) && (x<1432) && (y>266) && (y<696)) {
|
||||
EffacerEcran(CouleurParNom("grey"));
|
||||
FermerGraphique();
|
||||
essay(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -100,14 +102,16 @@ int menu_principal(void){
|
||||
x=_X;
|
||||
y=_Y;
|
||||
if((x>68) && (x<488) && (y>266) && (y<696)){
|
||||
EffacerEcran(CouleurParNom("grey"));
|
||||
FermerGraphique();
|
||||
essay(3);
|
||||
}
|
||||
if((x>537) && (x<958) && (y>266) && (y<696)){
|
||||
EffacerEcran(CouleurParNom("white"));
|
||||
essay();
|
||||
FermerGraphique();
|
||||
essay(4);
|
||||
}
|
||||
if((x>1007) && (x<1432) && (y>266) && (y<696)) {
|
||||
EffacerEcran(CouleurParNom("grey"));
|
||||
FermerGraphique();
|
||||
essay(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,14 +126,16 @@ int menu_principal(void){
|
||||
x=_X;
|
||||
y=_Y;
|
||||
if((x>68) && (x<488) && (y>266) && (y<696)){
|
||||
EffacerEcran(CouleurParNom("grey"));
|
||||
FermerGraphique();
|
||||
essay(3);
|
||||
}
|
||||
if((x>537) && (x<958) && (y>266) && (y<696)){
|
||||
EffacerEcran(CouleurParNom("white"));
|
||||
essay();
|
||||
FermerGraphique();
|
||||
essay(4);
|
||||
}
|
||||
if((x>1007) && (x<1432) && (y>266) && (y<696)) {
|
||||
EffacerEcran(CouleurParNom("grey"));
|
||||
FermerGraphique();
|
||||
essay(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
50
timer.c
50
timer.c
@ -1,48 +1,12 @@
|
||||
#include "timer.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
#include <stdio.h>
|
||||
|
||||
unsigned long temps_ecoule = 0;
|
||||
unsigned long temps = Microsecondes();
|
||||
int time;
|
||||
int seconde_passee;
|
||||
int minutes = 0;
|
||||
int secondes = 0;
|
||||
//int a = 1;
|
||||
int temps_reference = 0;
|
||||
char afficher_temps[20];
|
||||
|
||||
int timer(void){
|
||||
//unsigned long temps_ecoule = 0;
|
||||
//unsigned long temps = Microsecondes();
|
||||
//int timer;
|
||||
//int seconde_passee;
|
||||
//int minutes = 0;
|
||||
//int secondes = 0;
|
||||
//int a = 1;
|
||||
//int temps_reference = 0;
|
||||
//char afficher_temps[20];
|
||||
|
||||
temps_ecoule = (int) (Microsecondes() - temps);
|
||||
if (temps_reference<temps_ecoule){
|
||||
temps_reference +=1;
|
||||
time = (int) (temps_ecoule / 1000000);
|
||||
if (time != seconde_passee){
|
||||
seconde_passee = time;
|
||||
secondes = time ;
|
||||
if (secondes >59){
|
||||
minutes = secondes/60;
|
||||
secondes = secondes - (minutes * 60);
|
||||
}
|
||||
ChoisirCouleurDessin(CouleurParNom("black"));
|
||||
RemplirRectangle(675,25,160,30);
|
||||
ChoisirCouleurDessin(CouleurParNom("white"));
|
||||
snprintf(afficher_temps,15,"Time : %02d : %02d",minutes,secondes);
|
||||
EcrireTexte(700,50,afficher_temps,1);
|
||||
}
|
||||
void timer(unsigned long* temps_ecoule, unsigned long temps_microsec){
|
||||
unsigned long temps_actuel = Microsecondes();
|
||||
if (temps_actuel > temps_microsec + 1000000){
|
||||
temps_microsec = temps_actuel;
|
||||
*temps_ecoule++;
|
||||
printf("%d",*temps_ecoule);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user