summaryrefslogtreecommitdiff
path: root/src/entity.h
blob: 464b81f58bb189230b677f67c6ba47e0069848c9 (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
30
31
32
33
34
35
36
37
#pragma once
#include "player.h"
#include "exit.h"
#include "deathpart.h"
#include <stdbool.h>

struct Game;

enum { ET_NONE = 0 };

typedef struct Entity Entity;
struct Entity {
	unsigned long uuid;
	Entity *(*update)(Entity *this, struct Game *g);
	Entity *(*draw)(Entity *this, struct Game *g);
	unsigned int type;
	int id;
	int pos[2];
	double vel[2];
	double rem[2];
	int width;
	int height;
	bool ignore_solids;
	bool bonk_ceiling;
	union {
		Player player;
		Exit exit;
		DeathPart deathpart;
	};
};

unsigned int entity_type(const char *type);
bool entity_collide(Entity *this, struct Game *g, int ox, int oy);
bool entity_meet(Entity *this, Entity *other);
Entity *entity_place_meeting(Entity *this, struct Game *g, unsigned int type);
void entity_move(Entity *this, struct Game *g);
Entity *entity_init(Entity *this, unsigned int type, int x, int y);