Project

General

Profile

Statistics
| Revision:

root / proj / src / project / include / proj_structures.h @ 373

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