-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenigf.c
126 lines (106 loc) · 1.94 KB
/
enigf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_image.h>
#include "joeur.h"
void init_enigme(enigme * e)//
{
e->p.x=0;
e->p.y=0;
e->img=NULL;
}
void generate_afficher (SDL_Surface * screen , char image [],enigme *e,int *alea)
{
int test=*alea ;
srand(time(NULL));
do{
*alea = 1+ rand()%3;
}while(*alea==test) ;
sprintf(image ,"fathallah/%d.png",*alea);
e->img = IMG_Load(image);
SDL_BlitSurface(e->img,NULL,screen,&(e->p)) ;
SDL_Flip(screen) ;
}
int solution_e (char image [])
{
int solution =0;
if(strcmp(image,"fathallah/1.png")==0)
{
solution =2 ;
}
else if(strcmp(image,"fathallah/2.png")==0)
{
solution =1;
}
else if(strcmp(image,"fathallah/3.png")==0)
{
solution =3;
}
/*else if(strcmp(image,"4.png")==0)
{
solution =1;
}
else if(strcmp(image,"5.png")==0)
{
solution =3;
}
else if(strcmp(image,"6.png")==0)
{
solution =3;
}
else if(strcmp(image,"7.png")==0)
{
solution =1;
}
else if(strcmp(image,"8.png")==0)
{
solution =2;
} */
return solution;
}
int resolution (int * running,int *run )//
{
SDL_Event event ;
int r=0 ;
SDL_PollEvent(&event);
switch(event.type)
{
case SDL_QUIT:
*running= 0 ;
*run = 0;
break ;
case SDL_KEYDOWN :
switch( event.key.keysym.sym )
{
case SDLK_a:
r= 1;
break ;
case SDLK_z :
r= 2;
break;
case SDLK_e:
r=3 ;
break;
}
break ;
}
return r ;
}
void afficher_resultat (SDL_Surface * screen,int s,int r,enigme *en)//
{
if (r==s)
{
en->img=IMG_Load("fathallah/11.png");
SDL_BlitSurface(en->img, NULL, screen, &(en->p)) ;
SDL_Flip(screen);
}
else
{
en->img=IMG_Load("fathallah/00.png");
SDL_BlitSurface(en->img, NULL, screen, &(en->p)) ;
SDL_Flip(screen);
}
}