Skip to content
Snippets Groups Projects
Commit fb16df04 authored by Arnaud Albiez's avatar Arnaud Albiez
Browse files

Correction affichage_grid

parent 47a54d51
No related merge requests found
......@@ -55,7 +55,7 @@ struct Grid *init_level(const char *file_path)
// on lit la première ligne du fichier
fgets(line, 100, file);
sscanf(line, "%d %d %d", &number_column, &number_row, &number_goals);
struct Grid *grid = new_grid(number_row, number_column);
struct Grid *grid = new_grid(number_column, number_row);
int current_row = 0;
grid->number_goal = number_goals;
grid->tabGoal = malloc(number_goals * (sizeof(struct Goal)));
......@@ -80,13 +80,14 @@ struct Grid *init_level(const char *file_path)
}
else
{
change_cell_grid(grid, current_row, current_column, buffer[0]);
change_cell_grid(grid, current_column, current_row, buffer[0]);
}
current_column += 1;
buffer += 1;
}
current_row += 1;
}
// fermeture du fichier
fclose(file);
return grid;
......@@ -125,9 +126,9 @@ int get_goal(struct Grid *grid, int col, int row)
void Affichage_grid(struct Grid *grid)
{
for (int col = 0; col < grid->column_number; col++)
for (int row = 0; row < grid->row_number; row++)
{
for (int row = 0; row < grid->row_number; row++)
for (int col = 0; col < grid->column_number; col++)
{
switch (get_grid(grid, col, row))
{
......
......@@ -40,13 +40,13 @@ struct Grid *new_grid(int width, int height);
struct Grid *init_level(const char *file_path);
enum CaseType get_grid(struct Grid *grid, int x, int y);
enum CaseType get_grid(struct Grid *grid, int col, int row);
int get_goal(struct Grid *grid, int x, int y);
int get_goal(struct Grid *grid, int col, int row);
void Affichage_grid(struct Grid *grid);
void change_cell_grid(struct Grid *grid, int x, int y, enum CaseType new_valeur);
void change_cell_grid(struct Grid *grid, int col, int row, enum CaseType new_valeur);
void free_grid(struct Grid *grid);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment