root / proj / include / proj_structures.h @ 339
History | View | Annotate | Download (3.49 KB)
1 | 312 | up20180655 | #ifndef PROJ_STRUCTURES_H_INCLUDED
|
---|---|---|---|
2 | #define PROJ_STRUCTURES_H_INCLUDED
|
||
3 | |||
4 | #include <stdint.h> |
||
5 | 320 | up20180655 | #include "ent.h" |
6 | 312 | up20180655 | |
7 | 339 | up20180642 | /**
|
8 | * @brief Key presses.
|
||
9 | */
|
||
10 | typedef struct { |
||
11 | 336 | up20180642 | /// @brief W is pressed when 1
|
12 | 312 | up20180655 | uint8_t w_pressed : 1;
|
13 | 336 | up20180642 | /// @brief A is pressed when 1
|
14 | 312 | up20180655 | uint8_t a_pressed : 1;
|
15 | 336 | up20180642 | /// @brief S is pressed when 1
|
16 | 312 | up20180655 | uint8_t s_pressed : 1;
|
17 | 336 | up20180642 | /// @brief D is pressed when 1
|
18 | 312 | up20180655 | uint8_t d_pressed : 1;
|
19 | 336 | up20180642 | /// @brief Ctrl is pressed when 1
|
20 | 312 | up20180655 | uint8_t ctrl_pressed : 1;
|
21 | 336 | up20180642 | /// @brief Plus (+) is pressed when 1
|
22 | 312 | up20180655 | uint8_t plus_pressed : 1;
|
23 | 336 | up20180642 | /// @brief Minus (-) is pressed when 1
|
24 | 312 | up20180655 | uint8_t minus_pressed : 1;
|
25 | 336 | up20180642 | /// @brief Mouse left button is pressed when 1
|
26 | 312 | up20180655 | uint8_t lb_pressed : 1;
|
27 | } keys_t; |
||
28 | |||
29 | 339 | up20180642 | /**
|
30 | * @brief Information to transmit from host to remote.
|
||
31 | */
|
||
32 | 321 | up20180642 | typedef struct { |
33 | 312 | up20180655 | // host
|
34 | 336 | up20180642 | /// @brief Host player X-position
|
35 | 329 | up20180655 | int16_t host_x; |
36 | 336 | up20180642 | /// @brief Host player Y-postition
|
37 | 329 | up20180655 | int16_t host_y; |
38 | 336 | up20180642 | /// @brief Host player angle
|
39 | 329 | up20180655 | int16_t host_angle; |
40 | 336 | up20180642 | /// @brief Host player health
|
41 | 329 | up20180655 | int16_t host_health; |
42 | 336 | up20180642 | /// @brief Host player current health
|
43 | 329 | up20180655 | int16_t host_current_health; |
44 | 312 | up20180655 | |
45 | // remote
|
||
46 | 336 | up20180642 | /// @brief Remote player X-position
|
47 | 329 | up20180655 | int16_t remote_x; |
48 | 336 | up20180642 | /// @brief Remote player Y-postition
|
49 | 329 | up20180655 | int16_t remote_y; |
50 | 336 | up20180642 | /// @brief Remote player angle
|
51 | 329 | up20180655 | int16_t remote_angle; |
52 | 336 | up20180642 | /// @brief Remote player health
|
53 | 329 | up20180655 | int16_t remote_health; |
54 | 336 | up20180642 | /// @brief Remote player current health
|
55 | 329 | up20180655 | int16_t remote_current_health; |
56 | 312 | up20180655 | |
57 | // bullets
|
||
58 | 339 | up20180642 | /// @brief Number of bullets
|
59 | 329 | up20180655 | uint8_t no_bullets; |
60 | 339 | up20180642 | /// @brief X-position of the bullets
|
61 | 329 | up20180655 | int16_t *bullets_x; |
62 | 339 | up20180642 | /// @brief Y-position of the bullets
|
63 | 329 | up20180655 | int16_t *bullets_y; |
64 | 339 | up20180642 | /// @brief X-speed of the bullets
|
65 | 329 | up20180655 | int16_t *bullets_vx; |
66 | 339 | up20180642 | /// @brief Y-speed of the bullets
|
67 | 329 | up20180655 | int16_t *bullets_vy; |
68 | 339 | up20180642 | /// @brief Who shot each bullet
|
69 | 329 | up20180655 | bool *bullets_shooter; // false for host, true for remote |
70 | 312 | up20180655 | } host_info_t; |
71 | 339 | up20180642 | /**
|
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);
|
||
83 | 312 | up20180655 | |
84 | 339 | up20180642 | /**
|
85 | * @brief Information to transmit from remote to host.
|
||
86 | */
|
||
87 | 321 | up20180642 | typedef struct { |
88 | 336 | up20180642 | /// @brief Remote keys that are pressed
|
89 | 312 | up20180655 | keys_t remote_keys_pressed; |
90 | 336 | up20180642 | /// @brief Remote player angle
|
91 | 320 | up20180655 | double remote_angle;
|
92 | 312 | up20180655 | } remote_info_t; |
93 | 339 | up20180642 | /**
|
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);
|
||
103 | 312 | up20180655 | |
104 | 339 | up20180642 | /**
|
105 | * @brief Bullet event to transmit from remote to host.
|
||
106 | */
|
||
107 | 321 | up20180642 | typedef struct { |
108 | 336 | up20180642 | /// @brief New bullet signal from remote
|
109 | 320 | up20180655 | bool new_bullet;
|
110 | } bullet_info_t; |
||
111 | 339 | up20180642 | /**
|
112 | * @brief Construct bullet event.
|
||
113 | * @return Pointer to constructed bullet event, or NULL if failed
|
||
114 | */
|
||
115 | 324 | up20180642 | bullet_info_t* bullet_info_ctor(void);
|
116 | 339 | up20180642 | /**
|
117 | * @brief Destruct bullet event.
|
||
118 | * @param p Pointer to bullet event to be destructed
|
||
119 | */
|
||
120 | 320 | up20180655 | void bullet_info_dtor(bullet_info_t *p);
|
121 | |||
122 | 312 | up20180655 | #endif /* end of include guard: PROJ_STRUCTURES_H_INCLUDED */ |