fix probleme zone de jeu

This commit is contained in:
2024-12-15 18:56:12 +01:00
parent c5c2949538
commit ce2acefbc5
7 changed files with 52 additions and 13 deletions

13
read.c
View File

@@ -8,10 +8,15 @@ vect *fileToTab2D (const char *name_file, unsigned short int **tab,
vect *targets = malloc (sizeof (vect));
(*nbr_targets) = 0;
FILE *file = fopen (name_file, "r");
unsigned int x = 0, y = 1;
unsigned int x = 0, y = 0;
while (!feof (file))
{
char current = fgetc (file);
if (current == EOF)
{
break;
}
switch (current)
{
case '#':
@@ -32,7 +37,7 @@ vect *fileToTab2D (const char *name_file, unsigned short int **tab,
tab[x][y] = PLAYER;
break;
case '\n':
y = 0;
y = -1;
++x;
break;
default:
@@ -40,8 +45,8 @@ vect *fileToTab2D (const char *name_file, unsigned short int **tab,
break;
}
++y;
if (x >= N || y >= N)
if (x > N || y > N)
{
perror ("Level out of range !");
exit (-1);