Project

General

Profile

Statistics
| Revision:

root / proj / include / proj_func.h @ 351

History | View | Annotate | Download (4 KB)

1
#ifndef PROJ_FUNC_H_INCLUDED
2
#define PROJ_FUNC_H_INCLUDED
3

    
4
/**
5
 * @defgroup proj_func proj_func
6
 * @brief Project helper functions.
7
 *
8
 * @{
9
 */
10

    
11
#include "libs.h"
12
#include "proj_structures.h"
13

    
14
//#include <stdint.h>
15

    
16
/**
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
/**
24
 * @brief Update key presses.
25
 */
26
void update_key_presses(void);
27
/**
28
 * @brief Get key presses.
29
 * @return  keys_t containing key presses
30
 */
31
keys_t* (get_key_presses)(void);
32

    
33
/**
34
 * @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
 * @brief Updates movement variables.
56
 */
57
void update_movement(map_t *map, gunner_t *p, keys_t *keys, list_t *shooter_list);
58

    
59
/**
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
/**
71
 * @brief Update scale if the keys were pressed to change scale.
72
 */
73
void update_scale(void);
74

    
75
/**
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
void (shoot_bullet)(const gunner_t *shooter, list_t *bullet_list, const basic_sprite_t *bsp_bullet);
82
/**
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
void (update_game_state)(const map_t *map, list_t *shooter_list, list_t *bullet_list);
92

    
93
/**
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
void build_host_structure(host_info_t *p, gunner_t *host, gunner_t *remote);
100
/**
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
void build_remote_structure(remote_info_t *p, keys_t *keys, double angle);
107

    
108

    
109

    
110
/**
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
typedef struct {
126
    /// @brief Time since construction.
127
    int time;
128
    /// @brief Text.
129
    text_t *text;
130
} text_timer_t;
131
/**
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

    
153
/**
154
 * @}
155
 */
156

    
157
#endif /* end of include guard: PROJ_FUNC_H_INCLUDED */