|
Dungeonator
1.0.0
a dungeon generator library
|
declaration file for grid functions More...
#include <stdbool.h>#include <stdlib.h>#include <stdio.h>#include <assert.h>#include <string.h>#include "tile.h"Go to the source code of this file.
Data Structures | |
| struct | Grids |
Typedefs | |
| typedef Tile ** | data_t |
| typedef int ** | regions_t |
| typedef struct Grids | Grid |
Functions | |
| data_t | mallocGrid (int width, int height) |
| regions_t | mallocRegions (int width, int height) |
| void | fillGrid (Grid *grid, int x1, int y1, int x2, int y2, Tile value) |
| void | fillRegion (regions_t regions, int x1, int y1, int x2, int y2, int value) |
| bool | createGrid (int width, int height, Grid *grid) |
| void | printGridToString (char *str, size_t bufsz, Grid *grid) |
| void | printGrid (Grid *grid) |
| void | debugPrintGrid (Grid *grid, regions_t regions) |
| void | freeGrid (Grid *grid) |
| void | freeRegions (regions_t regions, int height) |
declaration file for grid functions
a file full of grid functions to allow for operations
a struct to allow access to both the data and width/height of the grid in one param
| typedef int** regions_t |
the type for the regions to be used by the connection algorithm in generate.h
| bool createGrid | ( | int | width, |
| int | height, | ||
| Grid * | grid | ||
| ) |
creates and returns a grid, initialized to be full of walls (true)
| [in] | width | the width of the grid |
| [in] | height | the height of the grid |
| [out] | grid | the created grid |
print a grid to stdout, but with the regions printed in hex for debugging
| [in] | grid | the grid to print |
| [in] | regions | the array of regions to print |
fill a rectangle inside a grid with a tile value
| [in,out] | grid | the grid to fill |
| [in] | x1 | the left edge of the rectangle (inclusive) |
| [in] | y1 | the top edge of the rectangle (inclusive) |
| [in] | x2 | the right edge of the rectangle (exclusive) |
| [in] | y2 | the bottom edge of the rectangle (exclusive) |
| [in] | value | the tile value to fill the grid with |
if you're confused what inclusive/exclusive means here, basically it just doesn't fill all the way to the edge since that creates unintuitive effects
| void fillRegion | ( | regions_t | regions, |
| int | x1, | ||
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| int | value | ||
| ) |
fill a rectangle inside regions grid with a region
| [in,out] | regions | the grid to fill |
| [in] | x1 | the left edge of the rectangle (inclusive) |
| [in] | y1 | the top edge of the rectangle (inclusive) |
| [in] | x2 | the right edge of the rectangle (exclusive) |
| [in] | y2 | the bottom edge of the rectangle (exclusive) |
| [in] | value | the int region value to fill the grid with |
if you're confused what inclusive/exclusive means here, basically it just doesn't fill all the way to the edge since that creates unintuitive effects
| void freeGrid | ( | Grid * | grid | ) |
free the memory to a grid
| [in] | grid | the grid to free |
using a grid after this point is undefined behavior
| void freeRegions | ( | regions_t | regions, |
| int | height | ||
| ) |
free the memory to a regions grid
| [in] | regions | the regions array to free |
| [in] | height | the height of the regions array (get this right!) |
using a grid after this point is undefined behavior
| data_t mallocGrid | ( | int | width, |
| int | height | ||
| ) |
allocate the appropriate heap memory for a maze and cast it into an array - doesn't do any initialization. reading from the array at this point is undefined behavior
| [in] | width | the width of the 2d array to allocate |
| [in] | height | the height of the 2d array to allocate |
| regions_t mallocRegions | ( | int | width, |
| int | height | ||
| ) |
allocate memory for the regions array
| [in] | width | the width of the 2d array to allocate |
| [in] | height | the height of the 2d array to allocate |
| void printGrid | ( | Grid * | grid | ) |
print a grid to stdout
| [in] | grid | the grid to print |
| void printGridToString | ( | char * | str, |
| size_t | bufsz, | ||
| Grid * | grid | ||
| ) |
an alternative print function to allow printing a grid to a string
| [out] | str | the string to write the printed grid to |
| [in] | bufsz | the size of the output buffer, the function will only print part of the grid if it's not large enough |
| [in] | grid | the grid to print |