forked from daveruiz/doom-nano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentities.h
60 lines (50 loc) · 1.38 KB
/
entities.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
#ifndef _entities_h
#define _entities_h
#include "types.h"
// Shortcuts
#define create_player(x, y) { \
create_coords((double) x + 0.5, (double) y + 0.5), \
create_coords(1, 0), \
create_coords(0, -0.66), \
0, \
100, \
}
#define create_enemy(x, y) create_entity(E_ENEMY, x, y, S_STAND, 100)
#define create_medikit(x, y) create_entity(E_MEDIKIT, x, y, S_STAND, 0)
#define create_key(x, y) create_entity(E_KEY, x, y, S_STAND, 0)
#define create_fireball(x, y, dir) create_entity(E_FIREBALL, x, y, S_STAND, dir)
// entity statuses
#define S_STAND 0
#define S_ALERT 1
#define S_FIRING 2
#define S_MELEE 3
#define S_HIT 4
#define S_DEAD 5
#define S_HIDDEN 6
#define S_OPEN 7
#define S_CLOSE 8
struct Player {
Coords pos;
Coords dir;
Coords plane;
double velocity;
uint8_t health;
uint8_t keys;
};
struct Entity {
UID uid;
Coords pos;
uint8_t state;
uint8_t health; // angle for fireballs
uint8_t distance;
uint8_t timer;
};
struct StaticEntity {
UID uid;
uint8_t x;
uint8_t y;
bool active;
};
Entity create_entity(uint8_t type, uint8_t x, uint8_t y, uint8_t initialState, uint8_t initialHealth);
StaticEntity create_static_entity(UID uid, uint8_t x, uint8_t y, bool active);
#endif