diff options
Diffstat (limited to 'src/entityimpl.h')
-rw-r--r-- | src/entityimpl.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/entityimpl.h b/src/entityimpl.h index 63aa91f..859b44c 100644 --- a/src/entityimpl.h +++ b/src/entityimpl.h @@ -2,17 +2,21 @@ #include "game.h" #include "cfg.h" #include "lzy.h" +#include "entitytag.h" #include <string.h> #define IMPL_UPDATE() static Entity*update(Entity*this,Game*g){(void)this,(void)g; #define IMPL_DRAW() static Entity*draw(Entity*this,Game*g){(void)this,(void)g; -#define IMPL_INIT(X) Entity *X##_init(Entity *this, int x, int y) { do { \ +#define IMPL_INIT(X) __attribute__((constructor)) static void init_tag() { \ + entitytags[num_entitytags++] = #X; \ +} \ +Entity *X##_init(Entity *this, int x, int y) { do { \ memset(this, 0, sizeof(*this)); \ this->update = update; \ this->draw = draw; \ this->pos[0] = x; \ this->pos[1] = y; \ - this->type = ET_##X; \ + this->type = entity_type(#X); \ } while(0); #define IMPL_INIT_END #define IMPL_END return this; } |