aboutsummaryrefslogtreecommitdiff
path: root/map.h
blob: b06da7c73834917c3cf553e7455aa7e2f50ee473 (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
#ifndef MAP_H_
#define MAP_H_

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

enum MapTile_e {
    EMPTY = 0,
    GOAL,
    WALL,
};

typedef enum MapTile_e MapTile;

enum Colors_e {
    EMPTY_COLOR = 1,
    GOAL_COLOR = 2,
    WALL_COLOR = 3,
    START_COLOR = 4,
};

// A map is a 2D array of MapTiles.
// Use as map[row][column]
typedef MapTile** Map;

// 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);

// Draw the map. Bet you didn't expect that. 
void draw_map(Map map, int width, int height, Position start);

#endif //MAP_H_