This commit is contained in:
Georgios Samaras
2024-12-17 01:25:37 +01:00
parent 0913b3f935
commit 8c5eef6a5b
5 changed files with 342 additions and 0 deletions
+10
View File
@@ -28,6 +28,10 @@ grid_at(Grid *grid, i32 x, i32 y) {
return grid->grid[y * grid->width + x];
}
static inline bool
grid_contains(Grid *grid, i32 x, i32 y) {
return x >= 0 && y >= 0 && x < grid->width && y < grid->height;
}
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#include <stdio.h>
@@ -53,6 +57,12 @@ typedef double f64;
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define CLAMP(x, lo, hi) ((x) < (lo) ? (lo) : (x) > (hi) ? (hi) : (x))
#define MIN3(a, b, c) MIN(MIN(a, b), c)
#define MAX3(a, b, c) MAX(MAX(a, b), c)
#define MIN4(a, b, c, d) MIN(MIN(a, b), MIN(c, d))
#define MAX4(a, b, c, d) MAX(MAX(a, b), MAX(c, d))
#define Kilobytes(x) ((u64) (x) << 10)
#define Megabytes(x) ((u64) (x) << 20)
#define Gigabytes(x) ((u64) (x) << 30)