root / proj / include / proj_structures.h @ 340
History | View | Annotate | Download (4.14 KB)
1 | 312 | up20180655 | #ifndef PROJ_STRUCTURES_H_INCLUDED
|
---|---|---|---|
2 | #define PROJ_STRUCTURES_H_INCLUDED
|
||
3 | |||
4 | 340 | up20180642 | /**
|
5 | * @defgroup proj_structures proj_structures
|
||
6 | * @brief Project structures.
|
||
7 | *
|
||
8 | * @{
|
||
9 | */
|
||
10 | |||
11 | 312 | up20180655 | #include <stdint.h> |
12 | 320 | up20180655 | #include "ent.h" |
13 | 312 | up20180655 | |
14 | 339 | up20180642 | /**
|
15 | 340 | up20180642 | * @}
|
16 | 339 | up20180642 | */
|
17 | 340 | up20180642 | |
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 | 339 | up20180642 | typedef struct { |
30 | 336 | up20180642 | /// @brief W is pressed when 1
|
31 | 312 | up20180655 | uint8_t w_pressed : 1;
|
32 | 336 | up20180642 | /// @brief A is pressed when 1
|
33 | 312 | up20180655 | uint8_t a_pressed : 1;
|
34 | 336 | up20180642 | /// @brief S is pressed when 1
|
35 | 312 | up20180655 | uint8_t s_pressed : 1;
|
36 | 336 | up20180642 | /// @brief D is pressed when 1
|
37 | 312 | up20180655 | uint8_t d_pressed : 1;
|
38 | 336 | up20180642 | /// @brief Ctrl is pressed when 1
|
39 | 312 | up20180655 | uint8_t ctrl_pressed : 1;
|
40 | 336 | up20180642 | /// @brief Plus (+) is pressed when 1
|
41 | 312 | up20180655 | uint8_t plus_pressed : 1;
|
42 | 336 | up20180642 | /// @brief Minus (-) is pressed when 1
|
43 | 312 | up20180655 | uint8_t minus_pressed : 1;
|
44 | 336 | up20180642 | /// @brief Mouse left button is pressed when 1
|
45 | 312 | up20180655 | uint8_t lb_pressed : 1;
|
46 | } keys_t; |
||
47 | |||
48 | 339 | up20180642 | /**
|
49 | 340 | up20180642 | * @}
|
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 | 339 | up20180642 | * @brief Information to transmit from host to remote.
|
62 | */
|
||
63 | 321 | up20180642 | typedef struct { |
64 | 312 | up20180655 | // host
|
65 | 336 | up20180642 | /// @brief Host player X-position
|
66 | 329 | up20180655 | int16_t host_x; |
67 | 336 | up20180642 | /// @brief Host player Y-postition
|
68 | 329 | up20180655 | int16_t host_y; |
69 | 336 | up20180642 | /// @brief Host player angle
|
70 | 329 | up20180655 | int16_t host_angle; |
71 | 336 | up20180642 | /// @brief Host player health
|
72 | 329 | up20180655 | int16_t host_health; |
73 | 336 | up20180642 | /// @brief Host player current health
|
74 | 329 | up20180655 | int16_t host_current_health; |
75 | 312 | up20180655 | |
76 | // remote
|
||
77 | 336 | up20180642 | /// @brief Remote player X-position
|
78 | 329 | up20180655 | int16_t remote_x; |
79 | 336 | up20180642 | /// @brief Remote player Y-postition
|
80 | 329 | up20180655 | int16_t remote_y; |
81 | 336 | up20180642 | /// @brief Remote player angle
|
82 | 329 | up20180655 | int16_t remote_angle; |
83 | 336 | up20180642 | /// @brief Remote player health
|
84 | 329 | up20180655 | int16_t remote_health; |
85 | 336 | up20180642 | /// @brief Remote player current health
|
86 | 329 | up20180655 | int16_t remote_current_health; |
87 | 312 | up20180655 | |
88 | // bullets
|
||
89 | 339 | up20180642 | /// @brief Number of bullets
|
90 | 329 | up20180655 | uint8_t no_bullets; |
91 | 339 | up20180642 | /// @brief X-position of the bullets
|
92 | 329 | up20180655 | int16_t *bullets_x; |
93 | 339 | up20180642 | /// @brief Y-position of the bullets
|
94 | 329 | up20180655 | int16_t *bullets_y; |
95 | 339 | up20180642 | /// @brief X-speed of the bullets
|
96 | 329 | up20180655 | int16_t *bullets_vx; |
97 | 339 | up20180642 | /// @brief Y-speed of the bullets
|
98 | 329 | up20180655 | int16_t *bullets_vy; |
99 | 339 | up20180642 | /// @brief Who shot each bullet
|
100 | 329 | up20180655 | bool *bullets_shooter; // false for host, true for remote |
101 | 312 | up20180655 | } host_info_t; |
102 | 339 | up20180642 | /**
|
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 | 312 | up20180655 | |
115 | 339 | up20180642 | /**
|
116 | 340 | up20180642 | * @}
|
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 | 339 | up20180642 | * @brief Information to transmit from remote to host.
|
129 | */
|
||
130 | 321 | up20180642 | typedef struct { |
131 | 336 | up20180642 | /// @brief Remote keys that are pressed
|
132 | 312 | up20180655 | keys_t remote_keys_pressed; |
133 | 336 | up20180642 | /// @brief Remote player angle
|
134 | 320 | up20180655 | double remote_angle;
|
135 | 312 | up20180655 | } remote_info_t; |
136 | 339 | up20180642 | /**
|
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 | 312 | up20180655 | |
147 | 339 | up20180642 | /**
|
148 | 340 | up20180642 | * @}
|
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 | 339 | up20180642 | * @brief Bullet event to transmit from remote to host.
|
162 | */
|
||
163 | 321 | up20180642 | typedef struct { |
164 | 336 | up20180642 | /// @brief New bullet signal from remote
|
165 | 320 | up20180655 | bool new_bullet;
|
166 | } bullet_info_t; |
||
167 | 339 | up20180642 | /**
|
168 | * @brief Construct bullet event.
|
||
169 | * @return Pointer to constructed bullet event, or NULL if failed
|
||
170 | */
|
||
171 | 324 | up20180642 | bullet_info_t* bullet_info_ctor(void);
|
172 | 339 | up20180642 | /**
|
173 | * @brief Destruct bullet event.
|
||
174 | * @param p Pointer to bullet event to be destructed
|
||
175 | */
|
||
176 | 320 | up20180655 | void bullet_info_dtor(bullet_info_t *p);
|
177 | |||
178 | 340 | up20180642 | /**
|
179 | * @}
|
||
180 | */
|
||
181 | |||
182 | 312 | up20180655 | #endif /* end of include guard: PROJ_STRUCTURES_H_INCLUDED */ |