From de7a497fd85e625c2bff52c569995542ca347654 Mon Sep 17 00:00:00 2001 From: Quinn Date: Fri, 14 Feb 2025 01:26:20 +0100 Subject: [PATCH] add a very basic vector2 implementation. --- src/util/vec2.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/util/vec2.h diff --git a/src/util/vec2.h b/src/util/vec2.h new file mode 100644 index 0000000..bf87b07 --- /dev/null +++ b/src/util/vec2.h @@ -0,0 +1,34 @@ +#ifndef VEC2_H +#define VEC2_H +#define VEC2_COMB2(a, b) a##b +#define VEC2_COMB1(a, b) VEC2_COMB2(a, b) +#endif + +#define VEC2_TYPE int + +#ifdef VEC2_TYPE + +// customising the linkage +#ifndef VEC2_LINKAGE +#define VEC2_LINKAGE static inline +#endif + +// customising the name +#ifndef VEC2_NAME +#define VEC2_NAME VEC2_COMB1(vec2_, VEC2_TYPE) +#endif // VEC2_NAME + +// defines a two-dimensional vector of a specific type +typedef struct { + VEC2_TYPE x; + VEC2_TYPE y; +} VEC2_NAME; + +// TODO: implement vector-based logic + +#undef VEC2_NAME +#undef VEC2_LINKAGE +#undef VEC2_TYPE +#elif __INCLUDE_LEVEL__ != 0 +#error define VEC2_TYPE before including +#endif // VEC2_TYPE