root / proj / include / proj_structures.h @ 343
History | View | Annotate | Download (4.15 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 | 342 | up20180655 | /*
|
88 | 312 | up20180655 | // 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 | 342 | up20180655 | */
|
102 | 312 | up20180655 | } host_info_t; |
103 | 339 | up20180642 | /**
|
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 | 312 | up20180655 | |
116 | 339 | up20180642 | /**
|
117 | 340 | up20180642 | * @}
|
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 | 339 | up20180642 | * @brief Information to transmit from remote to host.
|
130 | */
|
||
131 | 321 | up20180642 | typedef struct { |
132 | 336 | up20180642 | /// @brief Remote keys that are pressed
|
133 | 312 | up20180655 | keys_t remote_keys_pressed; |
134 | 336 | up20180642 | /// @brief Remote player angle
|
135 | 320 | up20180655 | double remote_angle;
|
136 | 312 | up20180655 | } remote_info_t; |
137 | 339 | up20180642 | /**
|
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 | 312 | up20180655 | |
148 | 339 | up20180642 | /**
|
149 | 340 | up20180642 | * @}
|
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 | 339 | up20180642 | * @brief Bullet event to transmit from remote to host.
|
163 | */
|
||
164 | 321 | up20180642 | typedef struct { |
165 | 336 | up20180642 | /// @brief New bullet signal from remote
|
166 | 320 | up20180655 | bool new_bullet;
|
167 | } bullet_info_t; |
||
168 | 339 | up20180642 | /**
|
169 | * @brief Construct bullet event.
|
||
170 | * @return Pointer to constructed bullet event, or NULL if failed
|
||
171 | */
|
||
172 | 324 | up20180642 | bullet_info_t* bullet_info_ctor(void);
|
173 | 339 | up20180642 | /**
|
174 | * @brief Destruct bullet event.
|
||
175 | * @param p Pointer to bullet event to be destructed
|
||
176 | */
|
||
177 | 320 | up20180655 | void bullet_info_dtor(bullet_info_t *p);
|
178 | |||
179 | 340 | up20180642 | /**
|
180 | * @}
|
||
181 | */
|
||
182 | |||
183 | 312 | up20180655 | #endif /* end of include guard: PROJ_STRUCTURES_H_INCLUDED */ |