summaryrefslogtreecommitdiff
path: root/src/entityimpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/entityimpl.h')
-rw-r--r--src/entityimpl.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/entityimpl.h b/src/entityimpl.h
index adc4c09..971ffc5 100644
--- a/src/entityimpl.h
+++ b/src/entityimpl.h
@@ -6,13 +6,18 @@
#include <string.h>
#define IMPL_UPDATE() static Entity * \
- update([[maybe_unused]] Entity *this, [[maybe_unused]] Game *g) {
+update([[maybe_unused]] Entity *this, [[maybe_unused]] Game *g) {
+
#define IMPL_DRAW() static Entity * \
- draw([[maybe_unused]] Entity *this, [[maybe_unused]] Game *g) {
-#define IMPL_INIT(X) __attribute__((constructor)) static void init_tag() { \
+draw([[maybe_unused]] Entity *this, [[maybe_unused]] Game *g) {
+
+#define IMPL_INIT(X) static Entity *init(Entity *this, int x, int y); \
+__attribute__((constructor)) static void init_tag() { \
+ entityinits[num_entitytags] = init; \
entitytags[num_entitytags++] = #X; \
} \
-Entity *X##_init(Entity *this, int x, int y) { do { \
+static Entity * \
+init(Entity *this, int x, int y) { do { \
memset(this, 0, sizeof(*this)); \
this->update = update; \
this->draw = draw; \
@@ -20,4 +25,5 @@ Entity *X##_init(Entity *this, int x, int y) { do { \
this->pos[1] = y; \
this->type = entity_type(#X); \
} while(0);
+
#define IMPL_END return this; }