Project

General

Profile

Statistics
| Revision:

root / proj / include / proj_func.h @ 345

History | View | Annotate | Download (4.01 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 "ent.h"
12
#include "text.h"
13
#include "proj_structures.h"
14

    
15
#include <stdint.h>
16

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

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

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

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

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

    
109

    
110

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

    
154
/**
155
 * @}
156
 */
157

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