hyperultra/src/entityimpl.h

27 lines
680 B
C
Raw Normal View History

2023-03-18 21:54:01 +01:00
#pragma once
#include "game.h"
#include "cfg.h"
#include "lzy.h"
2023-03-23 16:16:22 +01:00
#include "entitytag.h"
2023-03-18 21:54:01 +01:00
#include <string.h>
2023-03-26 09:11:55 +02:00
#define IMPL(X) static void \
X([[maybe_unused]] Entity *this, [[maybe_unused]] Game *g)
2023-03-26 07:45:46 +02:00
#define IMPL_INIT(X) static Entity *init(Entity *this, int x, int y); \
__attribute__((constructor)) static void init_tag() { \
2023-03-26 09:11:55 +02:00
entitytags[num_entitytags].init = init; \
entitytags[num_entitytags++].name = #X; \
2023-03-23 16:16:22 +01:00
} \
2023-03-26 07:45:46 +02:00
static Entity * \
init(Entity *this, int x, int y) { do { \
2023-03-18 21:54:01 +01:00
memset(this, 0, sizeof(*this)); \
this->update = update; \
this->draw = draw; \
this->pos[0] = x; \
this->pos[1] = y; \
2023-03-23 16:16:22 +01:00
this->type = entity_type(#X); \
2023-03-18 21:54:01 +01:00
} while(0);
2023-03-26 07:45:46 +02:00
2023-03-18 23:40:10 +01:00
#define IMPL_END return this; }