Dungeonator  1.0.0
a dungeon generator library
grid.h
Go to the documentation of this file.
1 #ifndef GRID_H
2 #define GRID_H
3 
11 #include <stdbool.h>
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <assert.h>
15 #include <string.h>
16 
17 #include "tile.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif // __cplusplus
22 
26  typedef Tile** data_t;
27 
31  typedef int** regions_t;
32 
36  typedef struct Grids {
40  int width;
44  int height;
49  } Grid;
50 
60  data_t mallocGrid(int width, int height);
61 
73  regions_t mallocRegions(int width, int height);
74 
89  void fillGrid(Grid* grid, int x1, int y1, int x2, int y2,
90  Tile value);
91 
106  void fillRegion(regions_t regions, int x1, int y1, int x2, int y2,
107  int value);
108 
118  bool createGrid(int width, int height, Grid* grid);
119 
127  void printGridToString(char* str, size_t bufsz, Grid* grid);
128 
134  void printGrid(Grid* grid);
135 
142  void debugPrintGrid(Grid* grid, regions_t regions);
143 
151  void freeGrid(Grid* grid);
152 
161  void freeRegions(regions_t regions, int height);
162 
163 #ifdef __cplusplus
164 }
165 #endif // __cplusplus
166 
167 #endif // !GRID_H
void printGridToString(char *str, size_t bufsz, Grid *grid)
Definition: grid.c:74
int ** regions_t
Definition: grid.h:31
void fillRegion(regions_t regions, int x1, int y1, int x2, int y2, int value)
Definition: grid.c:41
data_t mallocGrid(int width, int height)
Definition: grid.c:19
regions_t mallocRegions(int width, int height)
Definition: grid.c:23
void freeRegions(regions_t regions, int height)
Definition: grid.c:137
Tile ** data_t
Definition: grid.h:26
bool createGrid(int width, int height, Grid *grid)
Definition: grid.c:53
void debugPrintGrid(Grid *grid, regions_t regions)
Definition: grid.c:103
void printGrid(Grid *grid)
Definition: grid.c:94
void freeGrid(Grid *grid)
Definition: grid.c:133
void fillGrid(Grid *grid, int x1, int y1, int x2, int y2, Tile value)
Definition: grid.c:27
struct Grids Grid
Definition: grid.h:36
int height
Definition: grid.h:44
data_t data
Definition: grid.h:48
int width
Definition: grid.h:40
the include file for the potential tiles in a grid
enum Tiles Tile