aboutsummaryrefslogtreecommitdiff
path: root/map.h
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-03-20 22:57:32 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-03-20 22:57:32 +0300
commita08e4c138734fd59246e70260c51b9d7b68be007 (patch)
tree52d8eec4570acbea5d91177a05549abd9798c5b9 /map.h
parenta0604cc84ef5286d7fe42a1ad125e654ce7eacf6 (diff)
Add ability to read plaintext maps from files
Diffstat (limited to 'map.h')
-rw-r--r--map.h16
1 files changed, 16 insertions, 0 deletions
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);