Project

General

Profile

Statistics
| Revision:

root / proj / project / include / proj_func.h @ 355

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