fix emplacement de function

This commit is contained in:
2025-01-08 13:33:42 +01:00
parent 2d6a251f3c
commit 488f9a5fb0
6 changed files with 82 additions and 77 deletions

View File

@@ -7,6 +7,7 @@
#include "../include/function.h"
#include "../include/display.h"
#include "../include/read.h"
#include <SDL2/SDL_events.h>
#include <SDL2/SDL_image.h>
@@ -435,38 +436,6 @@ int inGameLoop (char **tab2d, vect *dim_tab, vect *playerPos, vect *targets,
return -1;
}
/**
*
* \brief La fonction permet de retranscrire un niveau creer du tableau vers le fichier.txt
* \param filename Le nom du fichier a remplir.
* \param tab2d Le tableau 2d carre.
*/
void save_grid_to_file(int filename, char **tab2D) {
char path[250];
snprintf(path, sizeof(path), "maps/custom_%d.txt", filename);
FILE *file = fopen(path, "w");
// Parcours et sauvegarde du tableau 2D dans le fichier
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 20; j++) {
switch (tab2D[i][j]) {
case EMPTY: fputc(' ',file);break;
case WALL: fputc('#',file); break;
case BOX: fputc('C',file);break;
case TARGET: fputc('I',file); break;
case BOX_ON_TARGET: fputc(' ',file); break;
case PLAYER: fputc('P',file); break;
case PLAYER_ON_TARGET: fputc('P',file); break;
default: return;
}
}
fputc('\n',file); // Nouvelle ligne pour chaque ligne du tableau
}
fclose(file);
}
/**
*