diff options
author | kdx <kdx.42@42l.fr> | 2023-03-26 05:45:46 +0000 |
---|---|---|
committer | kdx <kdx.42@42l.fr> | 2023-03-26 05:45:46 +0000 |
commit | 20d86d093f1783a2a8135c27bcea5e41cce24bb5 (patch) | |
tree | 3d25fc33f1a14210bbed377272c73ea9a71094e9 /src/entityimpl.h | |
parent | aed7f6fa32843256b20224d1ef9f9c2d003e0e58 (diff) | |
download | hyperultra-20d86d093f1783a2a8135c27bcea5e41cce24bb5.tar.gz |
entity init by name
Diffstat (limited to 'src/entityimpl.h')
-rw-r--r-- | src/entityimpl.h | 14 |
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; } |