-
Notifications
You must be signed in to change notification settings - Fork 21
/
entities.h
56 lines (48 loc) · 1.57 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
#ifndef _entities_h
#define _entities_h
#include <stdint.h>
#include <stdbool.h>
#include "types.h"
// Shortcuts
//#define create_player(x, y) {create_coords((double) x + (double)0.5, (double) y + (double)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, 50)
#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)
#define create_door(x, y) create_entity(E_DOOR, x, y, S_STAND, 0)
// 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
typedef struct Player {
Coords pos;
Coords dir;
Coords plane;
double velocity;
uint8_t health;
uint8_t keys;
} Player;
typedef struct Entity {
UID uid;
Coords pos;
uint8_t state;
uint8_t health; // angle for fireballs
uint8_t distance;
uint8_t timer;
} Entity;
typedef struct StaticEntity {
UID uid;
uint8_t x;
uint8_t y;
bool active;
} StaticEntity;
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);
Player create_player(double x, double y);
#endif