Banjo API 1.1.0-alpha
Low-level C99 game development API
Loading...
Searching...
No Matches
maze.h
Go to the documentation of this file.
1
77#ifndef BJ_MAZE_H
78#define BJ_MAZE_H
79#include <banjo/api.h>
80#include <banjo/error.h>
81#include <banjo/random.h>
82
92#define BJ_MAZE_NO_CELL ((uint32_t)-1)
93
112
114#define BJ_MAZE_NORTH BJ_MAZE_DIR_NORTH
116#define BJ_MAZE_WEST BJ_MAZE_DIR_WEST
118#define BJ_MAZE_SOUTH BJ_MAZE_DIR_SOUTH
120#define BJ_MAZE_EAST BJ_MAZE_DIR_EAST
121
131struct bj_maze;
132
154 size_t width,
155 size_t height,
156 struct bj_error** error
157);
158
168 struct bj_maze* maze
169);
170
193 const struct bj_maze* maze,
194 size_t row,
195 size_t col
196);
197
220 struct bj_maze* maze,
221 uint32_t cell,
222 enum bj_maze_dir dir
223);
224
242 struct bj_maze* maze,
243 uint32_t cell,
244 enum bj_maze_dir dir
245);
246
261 const struct bj_maze* maze,
262 uint32_t cell,
263 enum bj_maze_dir dir
264);
265
277 struct bj_maze* maze
278);
279
293 struct bj_maze* maze
294);
295
306 const struct bj_maze* maze
307);
308
321 const struct bj_maze* maze
322);
323
349 const struct bj_maze* maze,
350 uint32_t cell,
351 enum bj_maze_dir dir
352);
353
354// --- Deprecated names (renamed on the road to 2.0) --------------------------
355
357BANJO_EXPORT bj_bool bj_maze_cell_opened(const struct bj_maze* maze, uint32_t cell,
358 enum bj_maze_dir dir);
364BANJO_EXPORT uint32_t bj_maze_adjacent(const struct bj_maze* maze, uint32_t cell,
365 enum bj_maze_dir dir);
366
367#endif
General-purpose definitions for Banjo API.
Recoverable error handling.
struct bj_maze bj_maze
Definition api.h:363
struct bj_error bj_error
Definition api.h:348
#define BANJO_EXPORT
Definition api.h:179
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:264
void bj_maze_close_all(struct bj_maze *maze)
Close every passage, leaving the maze as it came out of its constructor.
uint32_t bj_maze_cell_count(const struct bj_maze *maze)
How many cells the maze has.
bj_maze_dir
The four neighbour slots of a cell on a square grid.
Definition maze.h:106
bj_bool bj_maze_cell_is_open(const struct bj_maze *maze, uint32_t cell, enum bj_maze_dir dir)
Tell whether cell has a passage through slot dir.
uint8_t bj_maze_degree(const struct bj_maze *maze)
How many neighbour slots each cell has.
uint32_t bj_maze_adjacent_cell(const struct bj_maze *maze, uint32_t cell, enum bj_maze_dir dir)
Find what sits in slot dir of cell, wall or no wall.
bj_bool bj_maze_cell_opened(const struct bj_maze *maze, uint32_t cell, enum bj_maze_dir dir)
void bj_open_maze(struct bj_maze *maze)
void bj_maze_open_all(struct bj_maze *maze)
Open every passage there is, leaving one open field.
uint32_t bj_maze_adjacent(const struct bj_maze *maze, uint32_t cell, enum bj_maze_dir dir)
struct bj_maze * bj_create_maze_ortho2d(size_t width, size_t height, struct bj_error **error)
Allocate a new orthogonal 2D maze, with every wall still standing.
void bj_destroy_maze(struct bj_maze *maze)
Deletes a struct bj_maze object and releases associated memory.
uint32_t bj_close_maze_cell(struct bj_maze *maze, uint32_t cell, enum bj_maze_dir dir)
Put the wall back between cell and its neighbour through dir.
uint32_t bj_maze_ortho2d_cell(const struct bj_maze *maze, size_t row, size_t col)
Find the cell at a position of an orthogonal 2D maze.
uint32_t bj_open_maze_cell(struct bj_maze *maze, uint32_t cell, enum bj_maze_dir dir)
Carve a passage out of cell through slot dir.
void bj_close_maze(struct bj_maze *maze)
@ BJ_MAZE_DIR_NORTH
Towards the top of the grid.
Definition maze.h:107
@ BJ_MAZE_DIR_EAST
Towards the right of the grid.
Definition maze.h:110
@ BJ_MAZE_DIR_SOUTH
Towards the bottom of the grid.
Definition maze.h:109
@ BJ_MAZE_DIR_WEST
Towards the left of the grid.
Definition maze.h:108
Pseudo-random number generation API.