hyperultra/src/entityimpl.h

24 lines
694 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-25 21:59:23 +01:00
#define IMPL_UPDATE() static Entity * \
update([[maybe_unused]] Entity *this, [[maybe_unused]] Game *g) {
#define IMPL_DRAW() static Entity * \
draw([[maybe_unused]] Entity *this, [[maybe_unused]] Game *g) {
2023-03-23 16:16:22 +01:00
#define IMPL_INIT(X) __attribute__((constructor)) static void init_tag() { \
entitytags[num_entitytags++] = #X; \
} \
Entity *X##_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-18 23:40:10 +01:00
#define IMPL_END return this; }