From fb16df04759fa0f97633795204bd940bf0a6147b Mon Sep 17 00:00:00 2001 From: Arnaud Albiez <arnaud.albiez@poloper.org> Date: Sat, 19 Nov 2022 21:24:37 +0100 Subject: [PATCH] Correction affichage_grid --- grid.c | 9 +++++---- grid.h | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/grid.c b/grid.c index 3722686..0206184 100644 --- a/grid.c +++ b/grid.c @@ -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)) { diff --git a/grid.h b/grid.h index 34826ec..4fca30a 100644 --- a/grid.h +++ b/grid.h @@ -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); -- GitLab