Cub3D
 
Loading...
Searching...
No Matches
maze.h
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* maze.h :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: ppontet <ppontet@student.42lyon.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/08/05 19:23:53 by rdesprez #+# #+# */
9/* Updated: 2025/09/29 14:47:00 by rdesprez ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#ifndef MAZE_H
14# define MAZE_H
15
16# include "data_structure.h"
17# include <stddef.h>
18
19# define MAZE_N 1
20# define MAZE_S 2
21# define MAZE_E 4
22# define MAZE_W 8
23
27# define FT_RAND_MAX 32768
28
32# define MAZE_MIN_SIZE 3
33
37# define MAZE_MAX_SIZE 1000
38
39typedef struct s_posvec t_posvec;
40
45{
47 size_t len;
48 size_t capacity;
49};
50
57int maze_dir_x(int dir);
64int maze_dir_y(int dir);
71int maze_dir_opp(int dir);
72
79
86t_posvec *posvecnew(size_t size);
94int posvecpush(t_posvec *vec, t_pos2 data);
102int posvecpop(t_posvec *vec, t_pos2 *pos);
111int posvecremove(t_posvec *vec, size_t index,
112 t_pos2 *result);
118void posvecfree(t_posvec *vec);
120
127
133void ft_srand(unsigned int seed);
139unsigned int ft_rand(void);
146void array_shuffle(int *arr, int len);
155int cub_parse_generation_arg(char *gen, size_t *width,
156 size_t *height);
172
179int cub_spawn_objects(t_map_raoul *map, int key);
181
182#endif
Header file for all the types and structures of the project.
struct s_pos2 t_pos2
Definition data_structure.h:36
struct s_map_raoul t_map_raoul
Definition data_structure.h:31
int cub_spawn_objects(t_map_raoul *map, int key)
Spawns a key and a door in the maze.
Definition key_door.c:86
void array_shuffle(int *arr, int len)
Shuffle an array.
Definition random.c:43
void ft_srand(unsigned int seed)
Sets the initial random state from the given seed.
Definition random.c:32
int cub_parse_generation_arg(char *gen, size_t *width, size_t *height)
Parse the argument for generation.
Definition arg.c:53
t_map_raoul * cub_new_map_from_dimensions(char *dimensions)
Allocates a new map with the given dimension.
Definition gen.c:24
int cub_growing_tree(t_map_raoul *map)
Cub3D Maze Generator, uses dimensions from gen, store them in map and create a random perfect maze.
Definition growing_tree.c:112
unsigned int ft_rand(void)
Generate a random unsigned int.
Definition random.c:37
void posvecfree(t_posvec *vec)
Free the vector.
Definition posvec.c:75
t_posvec * posvecnew(size_t size)
Create a vector with an initial starting size.
Definition posvec.c:17
int posvecremove(t_posvec *vec, size_t index, t_pos2 *result)
Removes the element at the specified index from the vector if found.
Definition posvec.c:64
int posvecpop(t_posvec *vec, t_pos2 *pos)
Pops the last element of the vector if not empty.
Definition posvec.c:54
int posvecpush(t_posvec *vec, t_pos2 data)
Add a new element to the vector.
Definition posvec.c:35
int maze_dir_x(int dir)
Maze direction on x axis.
Definition maze_direction.c:15
int maze_dir_y(int dir)
Maze direction on y axis.
Definition maze_direction.c:24
struct s_posvec t_posvec
Definition maze.h:39
int maze_dir_opp(int dir)
Maze inverted direction on x and y axis.
Definition maze_direction.c:33
Vector implementation that stores t_pos2 objects.
Definition maze.h:45
t_pos2 * data
Definition maze.h:46
size_t len
Definition maze.h:47
size_t capacity
Definition maze.h:48