aboutsummaryrefslogtreecommitdiff
path: root/src/grid.h
diff options
context:
space:
mode:
authorHampus <hampus@hampusmat.com>2022-01-04 18:55:51 +0100
committerHampus <hampus@hampusmat.com>2022-01-05 20:09:27 +0100
commite3690eb85a9456cc1f3ccda751ae7d9fdf2d3b03 (patch)
tree2fdd32726d753495bf562102a0531101eaa1ddfd /src/grid.h
parent1bed3ac57906b26ef05b25c2bc5c1dca424dba4a (diff)
refactor: improve even more
Diffstat (limited to 'src/grid.h')
-rw-r--r--src/grid.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/grid.h b/src/grid.h
new file mode 100644
index 0000000..65fa01a
--- /dev/null
+++ b/src/grid.h
@@ -0,0 +1,59 @@
+#ifndef GRID_H
+#define GRID_H
+
+#include "position.h"
+
+typedef struct Dimensions
+{
+ unsigned int width;
+ unsigned int height;
+} Dimensions;
+
+typedef struct Grid
+{
+ char ***grid;
+ Dimensions dimens;
+} Grid;
+
+/**
+ * Returns a grid.
+ *
+ * @param width The grid width
+ * @param height The grid height
+ * @param fill A string to fill the new grid with
+ */
+Grid grid_create(unsigned int width, unsigned int height, char *fill);
+
+/*
+ * Returns a value from a position in a grid.
+ *
+ * @param grid A grid
+ * @param pos A grid position
+ */
+char *grid_get(Grid grid, Position pos);
+
+/*
+ * Sets the value of a position in a grid.
+ *
+ * @param grid A grid
+ * @param pos A grid position
+ * @param value A new value
+ */
+void grid_set(Grid grid, Position pos, char *value);
+
+/**
+ * Prints a grid.
+ *
+ * @param grid A grid
+ */
+void grid_print(Grid grid);
+
+/**
+ * Destroys a grid.
+ *
+ * @param grid A grid
+ */
+void grid_destroy(Grid grid);
+
+#endif
+