Revision 339
more changes
proj_structures.h | ||
---|---|---|
4 | 4 |
#include <stdint.h> |
5 | 5 |
#include "ent.h" |
6 | 6 |
|
7 |
typedef struct keys { |
|
7 |
/** |
|
8 |
* @brief Key presses. |
|
9 |
*/ |
|
10 |
typedef struct { |
|
8 | 11 |
/// @brief W is pressed when 1 |
9 | 12 |
uint8_t w_pressed : 1; |
10 | 13 |
/// @brief A is pressed when 1 |
... | ... | |
23 | 26 |
uint8_t lb_pressed : 1; |
24 | 27 |
} keys_t; |
25 | 28 |
|
29 |
/** |
|
30 |
* @brief Information to transmit from host to remote. |
|
31 |
*/ |
|
26 | 32 |
typedef struct { |
27 | 33 |
// host |
28 | 34 |
/// @brief Host player X-position |
... | ... | |
49 | 55 |
int16_t remote_current_health; |
50 | 56 |
|
51 | 57 |
// bullets |
58 |
/// @brief Number of bullets |
|
52 | 59 |
uint8_t no_bullets; |
60 |
/// @brief X-position of the bullets |
|
53 | 61 |
int16_t *bullets_x; |
62 |
/// @brief Y-position of the bullets |
|
54 | 63 |
int16_t *bullets_y; |
64 |
/// @brief X-speed of the bullets |
|
55 | 65 |
int16_t *bullets_vx; |
66 |
/// @brief Y-speed of the bullets |
|
56 | 67 |
int16_t *bullets_vy; |
68 |
/// @brief Who shot each bullet |
|
57 | 69 |
bool *bullets_shooter; // false for host, true for remote |
58 | 70 |
} host_info_t; |
71 |
/** |
|
72 |
* @brief Construct host information. |
|
73 |
* @param host Pointer to host gunner |
|
74 |
* @param remote Pointer to remote gunner |
|
75 |
* @return Pointer to constructed host information, or NULL if failed |
|
76 |
*/ |
|
77 |
host_info_t* host_info_ctor(gunner_t *host, gunner_t *remote); |
|
78 |
/** |
|
79 |
* @brief Destruct host information. |
|
80 |
* @param p Pointer to host information to be destructed |
|
81 |
*/ |
|
82 |
void host_info_dtor(host_info_t *p); |
|
59 | 83 |
|
84 |
/** |
|
85 |
* @brief Information to transmit from remote to host. |
|
86 |
*/ |
|
60 | 87 |
typedef struct { |
61 | 88 |
/// @brief Remote keys that are pressed |
62 | 89 |
keys_t remote_keys_pressed; |
63 | 90 |
/// @brief Remote player angle |
64 | 91 |
double remote_angle; |
65 | 92 |
} remote_info_t; |
93 |
/** |
|
94 |
* @brief Construct remote information. |
|
95 |
* @return Pointer to constructed remote information, or NULL if failed |
|
96 |
*/ |
|
97 |
remote_info_t* remote_info_ctor(void); |
|
98 |
/** |
|
99 |
* @brief Destruct remote information. |
|
100 |
* @param p Pointer to remote information to be destructed |
|
101 |
*/ |
|
102 |
void remote_info_dtor(remote_info_t *p); |
|
66 | 103 |
|
104 |
/** |
|
105 |
* @brief Bullet event to transmit from remote to host. |
|
106 |
*/ |
|
67 | 107 |
typedef struct { |
68 | 108 |
/// @brief New bullet signal from remote |
69 | 109 |
bool new_bullet; |
70 | 110 |
} bullet_info_t; |
71 |
|
|
72 |
host_info_t* host_info_ctor(gunner_t *host, gunner_t *remote); |
|
73 |
|
|
74 |
void host_info_dtor(host_info_t *p); |
|
75 |
|
|
76 |
remote_info_t* remote_info_ctor(void); |
|
77 |
|
|
78 |
void remote_info_dtor(remote_info_t *p); |
|
79 |
|
|
111 |
/** |
|
112 |
* @brief Construct bullet event. |
|
113 |
* @return Pointer to constructed bullet event, or NULL if failed |
|
114 |
*/ |
|
80 | 115 |
bullet_info_t* bullet_info_ctor(void); |
81 |
|
|
116 |
/** |
|
117 |
* @brief Destruct bullet event. |
|
118 |
* @param p Pointer to bullet event to be destructed |
|
119 |
*/ |
|
82 | 120 |
void bullet_info_dtor(bullet_info_t *p); |
83 | 121 |
|
84 | 122 |
#endif /* end of include guard: PROJ_STRUCTURES_H_INCLUDED */ |
Also available in: Unified diff