fix probleme zone de jeu
This commit is contained in:
13
read.c
13
read.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user