root / proj / include / proj_structures.h @ 354
History | View | Annotate | Download (4.15 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 |
float 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 |
float 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 |
*/
|
102 |
} host_info_t; |
103 |
/**
|
104 |
* @brief Construct host information.
|
105 |
* @param host Pointer to host gunner
|
106 |
* @param remote Pointer to remote gunner
|
107 |
* @return Pointer to constructed host information, or NULL if failed
|
108 |
*/
|
109 |
host_info_t* host_info_ctor(gunner_t *host, gunner_t *remote); |
110 |
/**
|
111 |
* @brief Destruct host information.
|
112 |
* @param p Pointer to host information to be destructed
|
113 |
*/
|
114 |
void host_info_dtor(host_info_t *p);
|
115 |
|
116 |
/**
|
117 |
* @}
|
118 |
*/
|
119 |
|
120 |
/**
|
121 |
* @defgroup remote_info_t remote_info_t
|
122 |
* @ingroup proj_structures
|
123 |
* @brief Remote info module.
|
124 |
*
|
125 |
* @{
|
126 |
*/
|
127 |
|
128 |
/**
|
129 |
* @brief Information to transmit from remote to host.
|
130 |
*/
|
131 |
typedef struct { |
132 |
/// @brief Remote keys that are pressed
|
133 |
keys_t remote_keys_pressed; |
134 |
/// @brief Remote player angle
|
135 |
double remote_angle;
|
136 |
} remote_info_t; |
137 |
/**
|
138 |
* @brief Construct remote information.
|
139 |
* @return Pointer to constructed remote information, or NULL if failed
|
140 |
*/
|
141 |
remote_info_t* remote_info_ctor(void);
|
142 |
/**
|
143 |
* @brief Destruct remote information.
|
144 |
* @param p Pointer to remote information to be destructed
|
145 |
*/
|
146 |
void remote_info_dtor(remote_info_t *p);
|
147 |
|
148 |
/**
|
149 |
* @}
|
150 |
*/
|
151 |
|
152 |
/**
|
153 |
* @defgroup bullet_info_t bullet_info_t
|
154 |
* @ingroup proj_structures
|
155 |
* @brief Bullet event module.
|
156 |
*
|
157 |
* @{
|
158 |
*/
|
159 |
|
160 |
|
161 |
/**
|
162 |
* @brief Bullet event to transmit from remote to host.
|
163 |
*/
|
164 |
typedef struct { |
165 |
/// @brief New bullet signal from remote
|
166 |
bool new_bullet;
|
167 |
} bullet_info_t; |
168 |
/**
|
169 |
* @brief Construct bullet event.
|
170 |
* @return Pointer to constructed bullet event, or NULL if failed
|
171 |
*/
|
172 |
bullet_info_t* bullet_info_ctor(void);
|
173 |
/**
|
174 |
* @brief Destruct bullet event.
|
175 |
* @param p Pointer to bullet event to be destructed
|
176 |
*/
|
177 |
void bullet_info_dtor(bullet_info_t *p);
|
178 |
|
179 |
/**
|
180 |
* @}
|
181 |
*/
|
182 |
|
183 |
#endif /* end of include guard: PROJ_STRUCTURES_H_INCLUDED */ |