1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#pragma once
#include "game.h"
#include "cfg.h"
#include "TZR.h"
#include "entitytag.h"
#include <string.h>
[[maybe_unused]] static void *_draw_begin;
[[maybe_unused]] static void *_draw;
[[maybe_unused]] static void *_draw_end;
[[maybe_unused]] static void *_update_begin;
[[maybe_unused]] static void *_update;
[[maybe_unused]] static void *_update_end;
#define IMPL(X) static void X(Entity *this, Game *g); \
__attribute__((constructor)) static void init_##X() { _##X = X; } \
static void X([[maybe_unused]] Entity *this, [[maybe_unused]] Game *g)
#define IMPL_INIT(X,P) static void init(Entity *, const char *, \
int, int, int, int); \
__attribute__((constructor)) static void init_tag(void) { \
entitytags[num_entitytags].init = init; \
entitytags[num_entitytags].parent = P; \
entitytags[num_entitytags++].name = #X; \
} \
static void _init(Entity *this); \
static void init(Entity *this, const char *name, int x, int y, int w, int h) { \
memset(this, 0, sizeof(*this)); \
this->update_begin = _update_begin; \
this->update = _update; \
this->update_end = _update_end; \
this->draw_begin = _draw_begin; \
this->draw = _draw; \
this->draw_end = _draw_end; \
this->name = name; \
this->pos[0] = x; \
this->pos[1] = y; \
this->width = w; \
this->height = h; \
this->type = entity_type(#X); \
_init(this); \
} \
static void _init([[maybe_unused]] Entity *this)
|