From 8084d5da9ce147edf4399ac16d757d915e71c013 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:36:37 +0100 Subject: [PATCH] ask_lab_walls --- src/main/c/labyrinth.c | 15 +++++++++++++++ src/main/c/labyrinth.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 06def76..5acb7d5 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -115,3 +115,18 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire return 0; } +void ask_lab_walls(Field_State** field, unsigned short len_x, unsigned short len_y){ + unsigned short x, y; + short a; + + init_field(field, len_x, len_y); + + do { + a = get_wall_input(&x, &y, len_x, len_y); + if (a == 0){ + set_wall(field, x, y); + show_solution(field, len_x, len_y); + } + } while (a != 1); +} + diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index c50580c..c731167 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -12,5 +12,6 @@ void show_solution(Field_State** field, unsigned short len_x, unsigned short len unsigned short get_natural_number(char text[]); void ask_lab_dimensions(unsigned short *len_x, unsigned short *len_y); short get_wall_input(unsigned short *x, unsigned short *y, unsigned short len_x, unsigned short len_y); +void ask_lab_walls(Field_State** field, unsigned short len_x, unsigned short len_y); #endif // TEST_H