summaryrefslogtreecommitdiff
path: root/src/entityimpl.h
blob: 971ffc520c009b67d20eb3886b1331a3a129f6f3 (plain)
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
#pragma once
#include "game.h"
#include "cfg.h"
#include "lzy.h"
#include "entitytag.h"
#include <string.h>

#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) {

#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; \
} \
static Entity * \
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 = entity_type(#X); \
} while(0);

#define IMPL_END return this; }