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