-
Notifications
You must be signed in to change notification settings - Fork 1
/
Entity.h
61 lines (49 loc) · 1.02 KB
/
Entity.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef B2BSAND_ENTITY_H
#define B2BSAND_ENTITY_H
#include <stdint.h>
#include <stdbool.h>
#include "Graphics.h"
#define MAX_ENTITIES 65536
#define FREE_ID -1
#define NO_FREE_ID_FOUND -1
typedef uint32_t EntityID;
typedef struct{
float x;
float y;
} Position;
typedef struct{
float vx;
float vy;
} Velocity;
typedef struct{
int32_t width;
int32_t height;
} Dimension;
typedef struct {
float angle;
} Rotation;
typedef enum{
NO_COLLIDE,
SOLID
} CollisionType;
typedef struct{
CollisionType type;
} Collider;
typedef struct{
bool listens;
} InputListener;
typedef struct{
int32_t highestId;
int16_t id[MAX_ENTITIES];
//Base
Position positions[MAX_ENTITIES];
Dimension dimensions[MAX_ENTITIES];
Rotation rotation[MAX_ENTITIES];
//Optional components
Collider collider[MAX_ENTITIES];
Velocity* velocity[MAX_ENTITIES];
Sprite* sprites[MAX_ENTITIES];
//Input
InputListener inputListeners[MAX_ENTITIES];
} EntityData;
#endif //B2BSAND_ENTITY_H