main.c 12.7 KB
Newer Older
Valentin MEUNIER's avatar
Valentin MEUNIER committed
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
/*main.c*/
/*15 juin 2021*/
/*make*/

#include "main.h"

void end_sdl(char ok,char const* msg,SDL_Window* window, SDL_Renderer* renderer)
{
	char msg_formated[255];
	int l;

	if (!ok) 
	{	                             
		strncpy(msg_formated, msg, 250);
		l = strlen(msg_formated);           
		strcpy(msg_formated + l, " : %s\n");
		SDL_Log(msg_formated, SDL_GetError());
	}

	if (renderer != NULL) SDL_DestroyRenderer(renderer);
	if (window != NULL)   SDL_DestroyWindow(window);


	if (!ok) exit(EXIT_FAILURE);
}
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
26

Valentin MEUNIER's avatar
Valentin MEUNIER committed
27
28
void afficherEcranIntelligemment(SDL_Renderer *renderer,int **tab,int taille_cell)
{
Valentin MEUNIER's avatar
enfin    
Valentin MEUNIER committed
29
	int x=0;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
30
31
	SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0);
	SDL_RenderClear(renderer);
32
33
34
35
	SDL_SetRenderDrawColor(renderer,0,0,0,0);
 	SDL_DisplayMode screen;
	SDL_GetCurrentDisplayMode(0,&screen);
	int decalage_horizontale=(screen.w/taille_cell-P)*taille_cell/3;
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
36
	int decalage_vertical=(screen.h/taille_cell-N)*taille_cell/20;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
37

Valentin MEUNIER's avatar
enfin    
Valentin MEUNIER committed
38
	SDL_SetRenderDrawColor(renderer,0,0,0,0);
Valentin MEUNIER's avatar
disj    
Valentin MEUNIER committed
39
	int i1,j1,noeud=0;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
40
	
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
41
42
43
	for (int i=0;i<N;i++){
                for (int j=0;j<P;j++){
                        x=tab[j][i];
Valentin MEUNIER's avatar
disj    
Valentin MEUNIER committed
44
			i1=(noeud%P);
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
45
                        j1=((int)noeud/P);
Valentin MEUNIER's avatar
disj    
Valentin MEUNIER committed
46

Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
47
48
49
50
51
52
53
54
55
                        if (!(x & FLAG_N)){
                                SDL_RenderDrawLine(renderer,i1*taille_cell+decalage_horizontale,j1*taille_cell+decalage_vertical,(i1+1)*taille_cell+decalage_horizontale,j1*taille_cell+decalage_vertical); //mur au nord
                                }
                        if ((x & FLAG_S)!=2)
                                SDL_RenderDrawLine(renderer,i1*taille_cell+decalage_horizontale,(j1+1)*taille_cell+decalage_vertical,(i1+1)*taille_cell+decalage_horizontale,(j1+1)*taille_cell+decalage_vertical); //mur au sud
                        if ((x & FLAG_E)!=4)
                                SDL_RenderDrawLine(renderer,(i1+1)*taille_cell+decalage_horizontale,j1*taille_cell+decalage_vertical,(i1+1)*taille_cell+decalage_horizontale,(j1+1)*taille_cell+decalage_vertical); //mur à l'est
                        if ((x & FLAG_O)!=8)
                                SDL_RenderDrawLine(renderer,i1*taille_cell+decalage_horizontale,j1*taille_cell+decalage_vertical,i1*taille_cell+decalage_horizontale,(j1+1)*taille_cell+decalage_vertical); //mur à l'ouest
Valentin MEUNIER's avatar
Valentin MEUNIER committed
56

Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
57
                        noeud+=1;
58

Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
59
60
                }
        }
Valentin MEUNIER's avatar
Valentin MEUNIER committed
61
62
}

Valentin MEUNIER's avatar
enfin    
Valentin MEUNIER committed
63
64
65
66
67
68
69
int min(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}	
Valentin MEUNIER's avatar
Valentin MEUNIER committed
70
71


Valentin MEUNIER's avatar
Valentin MEUNIER committed
72
int main (int argc, char** argv)
Valentin MEUNIER's avatar
Valentin MEUNIER committed
73
{
Valentin MEUNIER's avatar
Valentin MEUNIER committed
74
	double p;
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
75
76

	//l'argument p regit l'affichage des murs : s'il vaut 0 il n'y a aucun mur, s'il vaut un on a un arbre
Valentin MEUNIER's avatar
Valentin MEUNIER committed
77
	if (argc==2)  p=atof(argv[1]);
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
78
79
	else p=0.75; 
	
Valentin MEUNIER's avatar
Valentin MEUNIER committed
80
81
82
83
84
85
	if (SDL_Init(SDL_INIT_VIDEO) == -1)
	{
		fprintf(stderr, "Erreur d'initialisation de la SDL : %s\n", SDL_GetError());
		return EXIT_FAILURE;
	}

Valentin MEUNIER's avatar
enfin    
Valentin MEUNIER committed
86
87
 	SDL_DisplayMode screen;
	SDL_GetCurrentDisplayMode(0,&screen);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
88
	SDL_Window *window;
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
89

Valentin MEUNIER's avatar
enfin    
Valentin MEUNIER committed
90
	window = SDL_CreateWindow("SDL2 Programme 0.1", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,screen.w,screen.h, SDL_WINDOW_RESIZABLE);
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
91
	
Valentin MEUNIER's avatar
Valentin MEUNIER committed
92
	if (window == 0) fprintf(stderr, "Erreur d'initialisation de la SDL : %s\n", SDL_GetError());
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
93
94
	
	SDL_SetWindowTitle(window, "Labyrinthe");
Valentin MEUNIER's avatar
Valentin MEUNIER committed
95
96
97
98
99

	SDL_Renderer *renderer;
	renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); /*  SDL_RENDERER_SOFTWARE */
	if (renderer == 0) fprintf(stderr, "Erreur d'initialisation de la SDL : %s\n", SDL_GetError());
	int running=1;
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
100
	srand(time(0));
Valentin MEUNIER's avatar
Valentin MEUNIER committed
101
	int noeuds=N*P;
Valentin MEUNIER's avatar
enfin    
Valentin MEUNIER committed
102
	int nb_aretes=2*N*P-N-P;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
103
	int **tab;
Valentin MEUNIER's avatar
enfin    
Valentin MEUNIER committed
104
105
	int cours=0;
	int taille_cell=min(screen.w/(P+2),screen.h/(N+2));
Valentin MEUNIER's avatar
Valentin MEUNIER committed
106
//	int * tab_parents;  a decommenter pour l'utilisation de Dijkstra
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
107
	//initialisation du graph
Valentin MEUNIER's avatar
enfin    
Valentin MEUNIER committed
108
109
	graph_t * graph=creer_graph(noeuds,nb_aretes);
	generation(graph);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
110
	graph=Fisher(graph,nb_aretes);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
111
	graph=kruskal(graph,noeuds,nb_aretes,&cours,p);
Valentin MEUNIER's avatar
enfin    
Valentin MEUNIER committed
112
	tab=tableau_ligne(graph,cours);
113

Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
	//initialisation des differentes textures
	SDL_Texture * texture,*texture_fin,* texture_elve,* texture_elve_reverse;

	texture_elve = load_texture_from_image("Elve_lign.png",renderer);
    	if (texture_elve == NULL) end_sdl(0, "Echec du chargement de l'image dans la texture", window, renderer);

    	texture_elve_reverse = load_texture_from_image("Elve_ligne_reverse.png",renderer);
    	if (texture_elve_reverse == NULL) end_sdl(0, "Echec du chargement de l'image dans la texture", window, renderer);
	
	texture = load_texture_from_image("road.png",renderer);
	if (texture==NULL) exit(EXIT_FAILURE);

	texture_fin = load_texture_from_image("roguelikeChar_transparent.png",renderer);
    	if (texture_fin==NULL) exit(EXIT_FAILURE);


Valentin MEUNIER's avatar
Valentin MEUNIER committed
130
	SDL_Event event;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
131
132
	
	//on initialise une fenêtre 2 pour une mini-map
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
133
134
	SDL_Window *window2;

Valentin MEUNIER's avatar
Valentin MEUNIER committed
135
	window2 = SDL_CreateWindow("SDL2 Programme 0.1", screen.w-screen.w/3, 0,screen.w/3,screen.h/3, SDL_WINDOW_RESIZABLE);
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
136
137
138
139
140
	
	if (window2 == 0) fprintf(stderr, "Erreur d'initialisation de la SDL : %s\n", SDL_GetError());
	
	SDL_SetWindowTitle(window2, "Carte d'exploration");

Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
141
	//on initialise le renderer de la mini-map
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
142
143
144
145
	SDL_Renderer *renderer2;
	renderer2 = SDL_CreateRenderer(window2, -1, SDL_RENDERER_ACCELERATED); /*  SDL_RENDERER_SOFTWARE */
	if (renderer2 == 0) fprintf(stderr, "Erreur d'initialisation de la SDL : %s\n", SDL_GetError());

Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
146
147
148
149
150
151
152
153
154
	//on initialise les textures pour la deuxième fenêtre
	SDL_Texture *texture2,*texture_fin2;

	texture2 = load_texture_from_image("road.png",renderer2);
	if (texture2==NULL) exit(EXIT_FAILURE);

	texture_fin2 = load_texture_from_image("roguelikeChar_transparent.png",renderer2);
    	if (texture_fin2==NULL) exit(EXIT_FAILURE);

Valentin MEUNIER's avatar
Valentin MEUNIER committed
155
	int pause=0;
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
156
157
158
159
160
161
162
163
164
165
166
	int noeud_dep=rand()%TAILLE;
	int right=1;
	int stand=0;
	int pos_x=noeud_dep%P*taille_cell;
	int pos_y=noeud_dep/P*taille_cell;
	float zoom = (float)taille_cell/(float)22;
	int temps=1;
	int deplacement=taille_cell;
	int noeud_arrive=rand()%TAILLE;
	int colli;
	int noeud_actuel;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
167
168
169
170
	int fin_mama=0;
	int relancer=0;
	int affiche_carte=0;
	int dijkstra_ok;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
171
	int * minimap=malloc((TAILLE+1)*sizeof(int));
Valentin MEUNIER's avatar
Valentin MEUNIER committed
172
173
174
	for (int iter=0;iter<TAILLE+1;iter++)
		minimap[iter]=0;
	int taille_cell2=min((screen.w/3)/(P+2),(screen.h/3)/(N+2));
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
175

Valentin MEUNIER's avatar
Valentin MEUNIER committed
176
	printf("l : relancer \np,SPACE : pause \ncroix : quitter \nm : afficher la carte complète du labyrinthe pendant 2 secondes\n");
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
177

Valentin MEUNIER's avatar
Valentin MEUNIER committed
178
179
	while (running)
	{
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
180
		noeud_actuel=pos_y*P/taille_cell+pos_x/taille_cell;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
181
182
		minimap[0]++;
		minimap[minimap[0]]=noeud_actuel;
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
183
		if (noeud_actuel==noeud_arrive)
Valentin MEUNIER's avatar
Valentin MEUNIER committed
184
			fin_mama=1;
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
185
		while (SDL_PollEvent(&event))
Valentin MEUNIER's avatar
Valentin MEUNIER committed
186
187
188
189
190
		{
			switch (event.type)
			{
				case SDL_QUIT:
					running = 0;
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
191
					break;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
192
193
194
195
196
197
198
199
200
201
202
203
204
				case SDL_WINDOWEVENT:
					switch (event.window.event)
					{
						case SDL_WINDOWEVENT_CLOSE:
							running = 0;
							break;  
						default:
							break;
					}
					break;
				case SDL_KEYDOWN:
					switch (event.key.keysym.sym)
					{
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
205
						case SDLK_l:
Valentin MEUNIER's avatar
Valentin MEUNIER committed
206
207
208
209
210
							relancer=1;
							break;
						case SDLK_SPACE:
						case SDLK_p:
							pause=!pause;
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
211
212
							break;
						case SDLK_m: //la fonction devra afficher la totalite du labyrinthe sans brouillard de guerre
Valentin MEUNIER's avatar
Valentin MEUNIER committed
213
214
215
216
							affiche_carte=1;
							break; 
						case SDLK_d:
							dijkstra_ok=1;
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
217
							break;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
						default:
							break;
					}
         		break;
			}
		}
/*		if (dijkstra_ok)
		{
			tab_parents=dijkstra(tab,graph->noeuds,noeuds_arrive);
			
		}
*/		if (affiche_carte && !pause)
		{
			afficherImage(renderer,window,tab,taille_cell,texture);
			affichage_fin(texture_fin,window,renderer,noeud_arrive/P,noeud_arrive%P,taille_cell);
			SDL_RenderPresent(renderer);
			temps++;
				if (temps>50)
				{
					affiche_carte=0;
					SDL_RenderClear(renderer);
					temps=0;
				}
		}
		if (relancer && !pause)
		{
			noeud_dep=rand()%TAILLE;
			right=1;
			stand=0;
			pos_x=noeud_dep%P*taille_cell;
			pos_y=noeud_dep/P*taille_cell;
			temps=1;
			noeud_arrive=rand()%TAILLE;
			relancer=0;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
252
			SDL_RenderClear(renderer2);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
253
			SDL_RenderPresent(renderer2);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
254
			for (int i=1; i<=minimap[0]; i++)
Valentin MEUNIER's avatar
Valentin MEUNIER committed
255
256
257
258
259
260
261
262
263
264
265
266
267
268
				minimap[i]=0;
			minimap[0]=1;
			minimap[1]=pos_y*P/taille_cell+pos_x/taille_cell;
			
		}
		else if (!pause)
		{
 			SDL_RenderClear(renderer2);
			for (int iter=1;iter<minimap[0];iter++)
			{
				peindreMap(texture2,window2,renderer2,minimap[iter],taille_cell2,tab);
				affichage_fin(texture_fin2,window2,renderer2,noeud_arrive/P,noeud_arrive%P,taille_cell2);
				point_minimap(renderer2,taille_cell2,taille_cell2*(noeud_actuel%P),taille_cell2*noeud_actuel/P);
			}	
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
269
			SDL_RenderPresent(renderer2);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
270
271
272
273
			
			const Uint8 *keystates = SDL_GetKeyboardState(NULL);
			if ((keystates[SDL_SCANCODE_UP]||keystates[SDL_SCANCODE_W])) 
			{	
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
274
				colli=collision_N(pos_x,pos_y,tab,taille_cell);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
275
276
277
				if(!colli)
				{
					if (right)
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
278
        					play_with_elve_N(texture_elve,texture,window,renderer,pos_x,pos_y,deplacement,zoom,tab,taille_cell,texture_fin,noeud_arrive);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
279
        				else
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
280
281
282
283
        					play_with_elve_N_l(texture_elve_reverse,texture,window,renderer,pos_x,pos_y,deplacement,zoom,tab,taille_cell,texture_fin,noeud_arrive);
        				pos_y=pos_y-deplacement;
        				stand=0;
				}
Valentin MEUNIER's avatar
Valentin MEUNIER committed
284
			}
Valentin MEUNIER's avatar
Valentin MEUNIER committed
285
286
			if ((keystates[SDL_SCANCODE_DOWN]||keystates[SDL_SCANCODE_S])) 
			{	
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
287
				colli=collision_S(pos_x,pos_y,tab,taille_cell);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
288
289
290
				if(!colli)
				{
					if (right)
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
291
        					play_with_elve_S(texture_elve,texture,window,renderer,pos_x,pos_y,deplacement,zoom,tab,taille_cell,texture_fin,noeud_arrive);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
292
        				else
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
293
294
295
        					play_with_elve_S_l(texture_elve_reverse,texture,window,renderer,pos_x,pos_y,deplacement,zoom,tab,taille_cell,texture_fin,noeud_arrive);
        				pos_y=pos_y+deplacement;
        				stand=0;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
296
        		}
Valentin MEUNIER's avatar
disj    
Valentin MEUNIER committed
297
			}
Valentin MEUNIER's avatar
Valentin MEUNIER committed
298
299
        	if ((keystates[SDL_SCANCODE_LEFT]||keystates[SDL_SCANCODE_A])) 
			{	
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
300
				colli=collision_O(pos_x,pos_y,tab,taille_cell);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
301
302
				if(!colli)
				{
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
303
					play_with_elve_O(texture_elve_reverse,texture,window,renderer,pos_x,pos_y,deplacement,zoom,tab,taille_cell,texture_fin,noeud_arrive);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
304
305
306
307
        			pos_x=pos_x-deplacement;
        			stand=0;
        			right=0;
        		}
Valentin MEUNIER's avatar
Valentin MEUNIER committed
308
			}
Valentin MEUNIER's avatar
Valentin MEUNIER committed
309
310
			if ((keystates[SDL_SCANCODE_RIGHT]||keystates[SDL_SCANCODE_D])) 
			{	
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
311
				colli=collision_E(pos_x,pos_y,tab,taille_cell);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
312
313
				if(!colli)
				{
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
314
					play_with_elve_E(texture_elve,texture,window,renderer,pos_x,pos_y,deplacement,zoom,tab,taille_cell,texture_fin,noeud_arrive);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
315
316
317
318
        			pos_x=pos_x+deplacement;
        			stand=0;
     				right=1;
     			}
319
			}
Valentin MEUNIER's avatar
Valentin MEUNIER committed
320
321
322
        	if (right)
			{
        		switch (stand){
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
        		        	case 0:
                				play_standstill_1(texture_elve,texture,window,renderer,pos_x,pos_y,zoom,tab,taille_cell,texture_fin,noeud_arrive);
                				stand=(stand+1)%7;
                				break;
            				case 2:
                				play_standstill_2(texture_elve,texture,window,renderer,pos_x,pos_y,zoom,tab,taille_cell,texture_fin,noeud_arrive);
                				stand=(stand+1)%7;
                				break;
            				case 4:
                				play_standstill_3(texture_elve,texture,window,renderer,pos_x,pos_y,zoom,tab,taille_cell,texture_fin,noeud_arrive);
                				stand=(stand+1)%7;
                				break;
            				case 6:
                				play_standstill_4(texture_elve,texture,window,renderer,pos_x,pos_y,zoom,tab,taille_cell,texture_fin,noeud_arrive);
                				stand=(stand+1)%7;
                				break;
            				default:
                				stand=(stand+1)%7;
						break;
        		    }
       			 }
        		else{
        			switch (stand){
        	    		case 0:
        	    		    play_standstill_1_l(texture_elve_reverse,texture,window,renderer,pos_x,pos_y,zoom,tab,taille_cell,texture_fin,noeud_arrive);
                			stand=(stand+1)%7;
                			break;
            			case 2:
                			play_standstill_2_l(texture_elve_reverse,texture,window,renderer,pos_x,pos_y,zoom,tab,taille_cell,texture_fin,noeud_arrive);
               	 			stand=(stand+1)%7;
                			break;
            			case 4:
                			play_standstill_3_l(texture_elve_reverse,texture,window,renderer,pos_x,pos_y,zoom,tab,taille_cell,texture_fin,noeud_arrive);
                			stand=(stand+1)%7;
                			break;
            			case 6:
                			play_standstill_4_l(texture_elve_reverse,texture,window,renderer,pos_x,pos_y,zoom,tab,taille_cell,texture_fin,noeud_arrive);
                			stand=(stand+1)%7;
                			break;
            			default:
                			stand=(stand+1)%7;
                		break;
            			}
        		}
Valentin MEUNIER's avatar
Valentin MEUNIER committed
367
368
369
370
			}
			if (fin_mama)
			{
				affichage_txt(window,renderer);
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
371
				temps++;
Valentin MEUNIER's avatar
Valentin MEUNIER committed
372
373
374
375
376
377
378
379
380
381
382
				if (temps>50)
					running=0;
        	}
			if (pause)
			{
				relancer=0;
				affiche_carte=0;
				affichage_txt(window, renderer);
			}
        	SDL_Delay(30);
        	SDL_RenderPresent(renderer);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
383
	}
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
384
385
386
387
388

	SDL_DestroyTexture(texture_elve_reverse);
	SDL_DestroyTexture(texture_elve);
	SDL_DestroyTexture(texture);
	SDL_DestroyTexture(texture_fin);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
389
390
391
392
393
394
395
396
	SDL_DestroyTexture(texture_fin2);
	SDL_DestroyTexture(texture2);
	free(minimap);	
	free(graph->liste);
	free(graph);
	for (int i=0; i<P; i++)
		free(tab[i]);
	free(tab);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
397
	end_sdl(1, "Normal ending", window, renderer);
Valentin MEUNIER's avatar
le    
Valentin MEUNIER committed
398
	end_sdl(1,"Normal ending",window2,renderer2);
Valentin MEUNIER's avatar
Valentin MEUNIER committed
399
	SDL_Quit();
Valentin MEUNIER's avatar
Valentin MEUNIER committed
400
401
	return 1;
}