root / proj / include / proj_structures.h @ 339
History | View | Annotate | Download (3.49 KB)
1 |
#ifndef PROJ_STRUCTURES_H_INCLUDED
|
---|---|
2 |
#define PROJ_STRUCTURES_H_INCLUDED
|
3 |
|
4 |
#include <stdint.h> |
5 |
#include "ent.h" |
6 |
|
7 |
/**
|
8 |
* @brief Key presses.
|
9 |
*/
|
10 |
typedef struct { |
11 |
/// @brief W is pressed when 1
|
12 |
uint8_t w_pressed : 1;
|
13 |
/// @brief A is pressed when 1
|
14 |
uint8_t a_pressed : 1;
|
15 |
/// @brief S is pressed when 1
|
16 |
uint8_t s_pressed : 1;
|
17 |
/// @brief D is pressed when 1
|
18 |
uint8_t d_pressed : 1;
|
19 |
/// @brief Ctrl is pressed when 1
|
20 |
uint8_t ctrl_pressed : 1;
|
21 |
/// @brief Plus (+) is pressed when 1
|
22 |
uint8_t plus_pressed : 1;
|
23 |
/// @brief Minus (-) is pressed when 1
|
24 |
uint8_t minus_pressed : 1;
|
25 |
/// @brief Mouse left button is pressed when 1
|
26 |
uint8_t lb_pressed : 1;
|
27 |
} keys_t; |
28 |
|
29 |
/**
|
30 |
* @brief Information to transmit from host to remote.
|
31 |
*/
|
32 |
typedef struct { |
33 |
// host
|
34 |
/// @brief Host player X-position
|
35 |
int16_t host_x; |
36 |
/// @brief Host player Y-postition
|
37 |
int16_t host_y; |
38 |
/// @brief Host player angle
|
39 |
int16_t host_angle; |
40 |
/// @brief Host player health
|
41 |
int16_t host_health; |
42 |
/// @brief Host player current health
|
43 |
int16_t host_current_health; |
44 |
|
45 |
// remote
|
46 |
/// @brief Remote player X-position
|
47 |
int16_t remote_x; |
48 |
/// @brief Remote player Y-postition
|
49 |
int16_t remote_y; |
50 |
/// @brief Remote player angle
|
51 |
int16_t remote_angle; |
52 |
/// @brief Remote player health
|
53 |
int16_t remote_health; |
54 |
/// @brief Remote player current health
|
55 |
int16_t remote_current_health; |
56 |
|
57 |
// bullets
|
58 |
/// @brief Number of bullets
|
59 |
uint8_t no_bullets; |
60 |
/// @brief X-position of the bullets
|
61 |
int16_t *bullets_x; |
62 |
/// @brief Y-position of the bullets
|
63 |
int16_t *bullets_y; |
64 |
/// @brief X-speed of the bullets
|
65 |
int16_t *bullets_vx; |
66 |
/// @brief Y-speed of the bullets
|
67 |
int16_t *bullets_vy; |
68 |
/// @brief Who shot each bullet
|
69 |
bool *bullets_shooter; // false for host, true for remote |
70 |
} host_info_t; |
71 |
/**
|
72 |
* @brief Construct host information.
|
73 |
* @param host Pointer to host gunner
|
74 |
* @param remote Pointer to remote gunner
|
75 |
* @return Pointer to constructed host information, or NULL if failed
|
76 |
*/
|
77 |
host_info_t* host_info_ctor(gunner_t *host, gunner_t *remote); |
78 |
/**
|
79 |
* @brief Destruct host information.
|
80 |
* @param p Pointer to host information to be destructed
|
81 |
*/
|
82 |
void host_info_dtor(host_info_t *p);
|
83 |
|
84 |
/**
|
85 |
* @brief Information to transmit from remote to host.
|
86 |
*/
|
87 |
typedef struct { |
88 |
/// @brief Remote keys that are pressed
|
89 |
keys_t remote_keys_pressed; |
90 |
/// @brief Remote player angle
|
91 |
double remote_angle;
|
92 |
} remote_info_t; |
93 |
/**
|
94 |
* @brief Construct remote information.
|
95 |
* @return Pointer to constructed remote information, or NULL if failed
|
96 |
*/
|
97 |
remote_info_t* remote_info_ctor(void);
|
98 |
/**
|
99 |
* @brief Destruct remote information.
|
100 |
* @param p Pointer to remote information to be destructed
|
101 |
*/
|
102 |
void remote_info_dtor(remote_info_t *p);
|
103 |
|
104 |
/**
|
105 |
* @brief Bullet event to transmit from remote to host.
|
106 |
*/
|
107 |
typedef struct { |
108 |
/// @brief New bullet signal from remote
|
109 |
bool new_bullet;
|
110 |
} bullet_info_t; |
111 |
/**
|
112 |
* @brief Construct bullet event.
|
113 |
* @return Pointer to constructed bullet event, or NULL if failed
|
114 |
*/
|
115 |
bullet_info_t* bullet_info_ctor(void);
|
116 |
/**
|
117 |
* @brief Destruct bullet event.
|
118 |
* @param p Pointer to bullet event to be destructed
|
119 |
*/
|
120 |
void bullet_info_dtor(bullet_info_t *p);
|
121 |
|
122 |
#endif /* end of include guard: PROJ_STRUCTURES_H_INCLUDED */ |