From a08e4c138734fd59246e70260c51b9d7b68be007 Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Fri, 20 Mar 2026 22:57:32 +0300 Subject: Add ability to read plaintext maps from files --- map.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'map.h') diff --git a/map.h b/map.h index 03da971..a4cc971 100644 --- a/map.h +++ b/map.h @@ -34,6 +34,22 @@ unsigned int neighbours(Position neighbour_array[], Position pos, size_t width, * TODO: formula for actual size */ Map rbt_maze_map(size_t width, size_t height, unsigned int seed); +/* Reads the map from a file, saves size in `width` and `height` + * + * FILE FORMAT IS AS FOLLOWS: + * {WIDTH}x{HEIGHT} + * {EMPTY_CHAR}{WALL_CHAR}{START_CHAR}{END_CHAR} + * {MAP, one line at a time} + * + * EXAMPLE: + * 10x4 + * .#@x + * .......x.. + * ....###... + * ....#.#... + * ..@....... */ +Map file_plaintext_map(char *filename, size_t *width, size_t *height, Position *start_pos, Position *end_pos); + /* Draw the map. Bet you didn't expect that. */ void draw_map(Map map, size_t width, size_t height, int offset_x, int offset_y, Position start, Position goal); -- cgit v1.2.3