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