root / proj / src / project / include / proj_func.h @ 375
History | View | Annotate | Download (3.79 KB)
1 | 156 | up20180655 | #ifndef PROJ_FUNC_H_INCLUDED
|
---|---|---|---|
2 | #define PROJ_FUNC_H_INCLUDED
|
||
3 | |||
4 | 340 | up20180642 | /**
|
5 | * @defgroup proj_func proj_func
|
||
6 | 357 | up20180642 | * @ingroup proj
|
7 | 340 | up20180642 | * @brief Project helper functions.
|
8 | *
|
||
9 | * @{
|
||
10 | */
|
||
11 | |||
12 | 351 | up20180642 | #include "libs.h" |
13 | 311 | up20180655 | #include "proj_structures.h" |
14 | 167 | up20180655 | |
15 | 351 | up20180642 | //#include <stdint.h>
|
16 | 200 | up20180655 | |
17 | 156 | up20180655 | /**
|
18 | 345 | up20180642 | * @brief Update key presses.
|
19 | */
|
||
20 | 240 | up20180655 | void update_key_presses(void); |
21 | 345 | up20180642 | /**
|
22 | * @brief Get key presses.
|
||
23 | * @return keys_t containing key presses
|
||
24 | */
|
||
25 | keys_t* (get_key_presses)(void);
|
||
26 | 240 | up20180655 | |
27 | /**
|
||
28 | 345 | up20180642 | * @brief Update mouse.
|
29 | */
|
||
30 | void update_mouse(struct packet *p); |
||
31 | /**
|
||
32 | * @brief Get pointer to mouse X-position.
|
||
33 | * @return Pointer to mouse X-position.
|
||
34 | */
|
||
35 | int16_t* get_mouse_X(void);
|
||
36 | /**
|
||
37 | * @brief Get pointer to mouse Y-position.
|
||
38 | * @return Pointer to mouse Y-position.
|
||
39 | */
|
||
40 | int16_t* get_mouse_Y(void);
|
||
41 | /**
|
||
42 | * @brief Get cursor angle relative to a gunner in the screen.
|
||
43 | * @param p Pointer to gunner
|
||
44 | * @return Angle of the mouse relative to the gunner
|
||
45 | */
|
||
46 | double get_mouse_angle(gunner_t *p);
|
||
47 | |||
48 | /**
|
||
49 | 240 | up20180655 | * @brief Updates movement variables.
|
50 | */
|
||
51 | 307 | up20180642 | void update_movement(map_t *map, gunner_t *p, keys_t *keys, list_t *shooter_list);
|
52 | 240 | up20180655 | |
53 | 341 | up20180642 | /**
|
54 | * @brief Get random spawn (actually, position) for new gunner.
|
||
55 | *
|
||
56 | * The new position cannot collide with the map, nor with any of the gunners
|
||
57 | * already in the list.
|
||
58 | * @param map Pointer to map
|
||
59 | * @param p Pointer to new gunner
|
||
60 | * @param l List of gunners that already exist
|
||
61 | */
|
||
62 | void (get_random_spawn)(const map_t *map, gunner_t *p, list_t *l); |
||
63 | |||
64 | 345 | up20180642 | /**
|
65 | * @brief Update scale if the keys were pressed to change scale.
|
||
66 | */
|
||
67 | void update_scale(void); |
||
68 | 171 | up20180655 | |
69 | 345 | up20180642 | /**
|
70 | * @brief Shoot a bullet.
|
||
71 | * @param shooter Pointer to gunner that shot the bullet
|
||
72 | * @param bullet_list List of the bullets in the map
|
||
73 | * @param bsp_bullet Basic sprite that will be used to render the bullet
|
||
74 | */
|
||
75 | 237 | up20180642 | void (shoot_bullet)(const gunner_t *shooter, list_t *bullet_list, const basic_sprite_t *bsp_bullet); |
76 | 345 | up20180642 | /**
|
77 | * @brief Update game state.
|
||
78 | *
|
||
79 | * This includes moving bullets accordingly, processing damages, collisions of
|
||
80 | * bullets with walls, melee damage for the gunners that have autonomous melee.
|
||
81 | * @param map Pointer to map
|
||
82 | * @param shooter_list List of shooters
|
||
83 | * @param bullet_list List of bullets in the map
|
||
84 | */
|
||
85 | 236 | up20180642 | void (update_game_state)(const map_t *map, list_t *shooter_list, list_t *bullet_list); |
86 | 231 | up20180655 | |
87 | 345 | up20180642 | /**
|
88 | * @brief Wrapper to easen filling of the host_info_t.
|
||
89 | * @param p Host info to fill
|
||
90 | * @param host Host gunner
|
||
91 | * @param remote Remote gunner
|
||
92 | */
|
||
93 | 342 | up20180655 | void build_host_structure(host_info_t *p, gunner_t *host, gunner_t *remote);
|
94 | 345 | up20180642 | /**
|
95 | * @brief Wrapper to easen filling of the remote_info_t.
|
||
96 | * @param p Remote info to fill
|
||
97 | * @param keys Key presses of remote
|
||
98 | * @param angle Mouse angle of remote
|
||
99 | */
|
||
100 | 320 | up20180655 | void build_remote_structure(remote_info_t *p, keys_t *keys, double angle); |
101 | |||
102 | 167 | up20180655 | |
103 | 345 | up20180642 | |
104 | 340 | up20180642 | /**
|
105 | * @}
|
||
106 | */
|
||
107 | |||
108 | /**
|
||
109 | * @defgroup text_timer_t text_timer_t
|
||
110 | * @ingroup proj_func
|
||
111 | * @brief Text timer.
|
||
112 | *
|
||
113 | * @{
|
||
114 | */
|
||
115 | |||
116 | /**
|
||
117 | * @brief Text timer.
|
||
118 | */
|
||
119 | 339 | up20180642 | typedef struct { |
120 | 340 | up20180642 | /// @brief Time since construction.
|
121 | 250 | up20180655 | int time;
|
122 | 340 | up20180642 | /// @brief Text.
|
123 | 250 | up20180655 | text_t *text; |
124 | } text_timer_t; |
||
125 | 345 | up20180642 | /**
|
126 | * @brief Construct timer
|
||
127 | * @param fnt Font used to render timer text
|
||
128 | * @return Pointer to constructed timer, or NULL if failed
|
||
129 | */
|
||
130 | text_timer_t* (text_timer_ctor)(const font_t *fnt);
|
||
131 | /**
|
||
132 | * @brief Destruct timer.
|
||
133 | * @param p Pointer to timer to be destructed
|
||
134 | */
|
||
135 | void (text_timer_dtor)(text_timer_t *p);
|
||
136 | /**
|
||
137 | * @brief Update timer, by incrementing the number of seconds.
|
||
138 | * @param p Pointer to timer
|
||
139 | */
|
||
140 | void (text_timer_update)(text_timer_t *p);
|
||
141 | /**
|
||
142 | * @brief Reset timer to 0.
|
||
143 | * @param p Pointer to timer
|
||
144 | */
|
||
145 | void (text_timer_reset)(text_timer_t *p);
|
||
146 | 250 | up20180655 | |
147 | 340 | up20180642 | /**
|
148 | * @}
|
||
149 | */
|
||
150 | 250 | up20180655 | |
151 | 156 | up20180655 | #endif /* end of include guard: PROJ_FUNC_H_INCLUDED */ |