root / proj / include / proj_structures.h @ 340
History | View | Annotate | Download (4.14 KB)
1 |
#ifndef PROJ_STRUCTURES_H_INCLUDED
|
---|---|
2 |
#define PROJ_STRUCTURES_H_INCLUDED
|
3 |
|
4 |
/**
|
5 |
* @defgroup proj_structures proj_structures
|
6 |
* @brief Project structures.
|
7 |
*
|
8 |
* @{
|
9 |
*/
|
10 |
|
11 |
#include <stdint.h> |
12 |
#include "ent.h" |
13 |
|
14 |
/**
|
15 |
* @}
|
16 |
*/
|
17 |
|
18 |
/**
|
19 |
* @defgroup keys_t keys_t
|
20 |
* @ingroup proj_structures
|
21 |
* @brief Keys pressed module.
|
22 |
*
|
23 |
* @{
|
24 |
*/
|
25 |
|
26 |
/**
|
27 |
* @brief Keys pressed.
|
28 |
*/
|
29 |
typedef struct { |
30 |
/// @brief W is pressed when 1
|
31 |
uint8_t w_pressed : 1;
|
32 |
/// @brief A is pressed when 1
|
33 |
uint8_t a_pressed : 1;
|
34 |
/// @brief S is pressed when 1
|
35 |
uint8_t s_pressed : 1;
|
36 |
/// @brief D is pressed when 1
|
37 |
uint8_t d_pressed : 1;
|
38 |
/// @brief Ctrl is pressed when 1
|
39 |
uint8_t ctrl_pressed : 1;
|
40 |
/// @brief Plus (+) is pressed when 1
|
41 |
uint8_t plus_pressed : 1;
|
42 |
/// @brief Minus (-) is pressed when 1
|
43 |
uint8_t minus_pressed : 1;
|
44 |
/// @brief Mouse left button is pressed when 1
|
45 |
uint8_t lb_pressed : 1;
|
46 |
} keys_t; |
47 |
|
48 |
/**
|
49 |
* @}
|
50 |
*/
|
51 |
|
52 |
/**
|
53 |
* @defgroup host_info_t host_info_t
|
54 |
* @ingroup proj_structures
|
55 |
* @brief Host info module.
|
56 |
*
|
57 |
* @{
|
58 |
*/
|
59 |
|
60 |
/**
|
61 |
* @brief Information to transmit from host to remote.
|
62 |
*/
|
63 |
typedef struct { |
64 |
// host
|
65 |
/// @brief Host player X-position
|
66 |
int16_t host_x; |
67 |
/// @brief Host player Y-postition
|
68 |
int16_t host_y; |
69 |
/// @brief Host player angle
|
70 |
int16_t host_angle; |
71 |
/// @brief Host player health
|
72 |
int16_t host_health; |
73 |
/// @brief Host player current health
|
74 |
int16_t host_current_health; |
75 |
|
76 |
// remote
|
77 |
/// @brief Remote player X-position
|
78 |
int16_t remote_x; |
79 |
/// @brief Remote player Y-postition
|
80 |
int16_t remote_y; |
81 |
/// @brief Remote player angle
|
82 |
int16_t remote_angle; |
83 |
/// @brief Remote player health
|
84 |
int16_t remote_health; |
85 |
/// @brief Remote player current health
|
86 |
int16_t remote_current_health; |
87 |
|
88 |
// bullets
|
89 |
/// @brief Number of bullets
|
90 |
uint8_t no_bullets; |
91 |
/// @brief X-position of the bullets
|
92 |
int16_t *bullets_x; |
93 |
/// @brief Y-position of the bullets
|
94 |
int16_t *bullets_y; |
95 |
/// @brief X-speed of the bullets
|
96 |
int16_t *bullets_vx; |
97 |
/// @brief Y-speed of the bullets
|
98 |
int16_t *bullets_vy; |
99 |
/// @brief Who shot each bullet
|
100 |
bool *bullets_shooter; // false for host, true for remote |
101 |
} host_info_t; |
102 |
/**
|
103 |
* @brief Construct host information.
|
104 |
* @param host Pointer to host gunner
|
105 |
* @param remote Pointer to remote gunner
|
106 |
* @return Pointer to constructed host information, or NULL if failed
|
107 |
*/
|
108 |
host_info_t* host_info_ctor(gunner_t *host, gunner_t *remote); |
109 |
/**
|
110 |
* @brief Destruct host information.
|
111 |
* @param p Pointer to host information to be destructed
|
112 |
*/
|
113 |
void host_info_dtor(host_info_t *p);
|
114 |
|
115 |
/**
|
116 |
* @}
|
117 |
*/
|
118 |
|
119 |
/**
|
120 |
* @defgroup remote_info_t remote_info_t
|
121 |
* @ingroup proj_structures
|
122 |
* @brief Remote info module.
|
123 |
*
|
124 |
* @{
|
125 |
*/
|
126 |
|
127 |
/**
|
128 |
* @brief Information to transmit from remote to host.
|
129 |
*/
|
130 |
typedef struct { |
131 |
/// @brief Remote keys that are pressed
|
132 |
keys_t remote_keys_pressed; |
133 |
/// @brief Remote player angle
|
134 |
double remote_angle;
|
135 |
} remote_info_t; |
136 |
/**
|
137 |
* @brief Construct remote information.
|
138 |
* @return Pointer to constructed remote information, or NULL if failed
|
139 |
*/
|
140 |
remote_info_t* remote_info_ctor(void);
|
141 |
/**
|
142 |
* @brief Destruct remote information.
|
143 |
* @param p Pointer to remote information to be destructed
|
144 |
*/
|
145 |
void remote_info_dtor(remote_info_t *p);
|
146 |
|
147 |
/**
|
148 |
* @}
|
149 |
*/
|
150 |
|
151 |
/**
|
152 |
* @defgroup bullet_info_t bullet_info_t
|
153 |
* @ingroup proj_structures
|
154 |
* @brief Bullet event module.
|
155 |
*
|
156 |
* @{
|
157 |
*/
|
158 |
|
159 |
|
160 |
/**
|
161 |
* @brief Bullet event to transmit from remote to host.
|
162 |
*/
|
163 |
typedef struct { |
164 |
/// @brief New bullet signal from remote
|
165 |
bool new_bullet;
|
166 |
} bullet_info_t; |
167 |
/**
|
168 |
* @brief Construct bullet event.
|
169 |
* @return Pointer to constructed bullet event, or NULL if failed
|
170 |
*/
|
171 |
bullet_info_t* bullet_info_ctor(void);
|
172 |
/**
|
173 |
* @brief Destruct bullet event.
|
174 |
* @param p Pointer to bullet event to be destructed
|
175 |
*/
|
176 |
void bullet_info_dtor(bullet_info_t *p);
|
177 |
|
178 |
/**
|
179 |
* @}
|
180 |
*/
|
181 |
|
182 |
#endif /* end of include guard: PROJ_STRUCTURES_H_INCLUDED */ |