diff options
Diffstat (limited to 'src/entityimpl.h')
-rw-r--r-- | src/entityimpl.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/entityimpl.h b/src/entityimpl.h new file mode 100644 index 0000000..afc9dc2 --- /dev/null +++ b/src/entityimpl.h @@ -0,0 +1,30 @@ +#pragma once +#include "game.h" +#include "cfg.h" +#include "lzr.h" +#include "entitytag.h" +#include <string.h> + +//[[maybe_unused]] static void *_draw; +//[[maybe_unused]] static void *_update; + +#define IMPL(X) static void X(Entity *this, Game *g); \ +static void X([[maybe_unused]] Entity *this, [[maybe_unused]] Game *g) +/*__attribute__((constructor)) static void init_##X() { _##X = X; } \ */ + +#define IMPL_INIT(X) static void init(Entity *this, int x, int y); \ +__attribute__((constructor)) static void init_tag() { \ + entitytags[num_entitytags].init = init; \ + entitytags[num_entitytags++].name = #X; \ +} \ +static void _init(Entity *this); \ +static void init(Entity *this, int x, int y) { \ + memset(this, 0, sizeof(*this)); \ + this->update = update; \ + this->draw = draw; \ + this->pos[0] = x; \ + this->pos[1] = y; \ + this->type = entity_type(#X); \ + _init(this); \ +} \ +static void _init([[maybe_unused]] Entity *this) |