commencement menu + addaptatif

This commit is contained in:
2024-12-21 11:45:49 +01:00
parent 40640698f7
commit 7f9433f505
12 changed files with 95 additions and 27 deletions

View File

@@ -5,6 +5,7 @@
#include "../include/function.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/**
* \brief La fonction permet de stocker la zone de jeu en fonction de la lecture d'un fichier.
@@ -68,3 +69,48 @@ vect *fileToTab2D (const char *name_file, char **tab,
fclose (file);
return targets;
}
int countCustomMaps(char *name_directory)
{
int nbr = 0;
char name_map[50] = "";
sprintf(name_map, "%s/custom_%d.txt",name_directory ,nbr);
FILE *file = fopen(name_map, "r");
while (file != NULL)
{
nbr++;
sprintf(name_map, "%s/custom_%d.txt",name_directory ,nbr);
printf("%p, %d, %s\n", file, nbr, name_map);
file = fopen(name_map, "r");
}
return nbr;
}
char ** generatorMenu(char *name_directory, int *x, int *y)
{
int nbr_custom = countCustomMaps("maps");
(*x) = 7;
(*y)= 5*(3+nbr_custom) +2;
char **menu = creatArea2D(*x,*y);
int i = 1;
for (i = 1;i < *y-1; ++i)
{
menu[4][i] = EMPTY;
}
int j,k ;
for (j = 5; j < *y; j+=5)
{
for (k = 1 ; k < 4; ++k)
{
menu[k][j] = EMPTY;
}
}
return menu;
}