aboutsummaryrefslogtreecommitdiff
path: root/map.h
blob: 7e174799b1fdd366c9196a8a329b98163ac6298f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef MAP_H_
#define MAP_H_

#include <stddef.h>
#include "structs.h"
#include "path.h"


/* Returns an empty map of given size */
Map empty_map(size_t width, size_t height);

/* Stores all the existing neighbours of pos in neighbour_array and returns their amount */
unsigned int neighbours(Position neighbour_array[], Position pos, size_t width, size_t height, \
        char visited[height][width]);

/* https://en.wikipedia.org/wiki/Maze_generation_algorithm#Randomized_depth-first_search 
 * WARNING: width and height are not the width and height of the returned map! 
 * 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. 
 * path could be NULL to draw a map with no path */
void draw_map(Map map, size_t width, size_t height, int offset_x, int offset_y, Position start, Position goal, Path path);

void print_map_out(Map map, size_t width, size_t height);

#endif /*MAP_H_ */