Project

General

Profile

Statistics
| Revision:

root / proj / src / project / include / proj_func.h @ 379

History | View | Annotate | Download (3.79 KB)

1
#ifndef PROJ_FUNC_H_INCLUDED
2
#define PROJ_FUNC_H_INCLUDED
3

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

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

    
15
//#include <stdint.h>
16

    
17
/**
18
 * @brief Update key presses.
19
 */
20
void update_key_presses(void);
21
/**
22
 * @brief Get key presses.
23
 * @return  keys_t containing key presses
24
 */
25
keys_t* (get_key_presses)(void);
26

    
27
/**
28
 * @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
 * @brief Updates movement variables.
50
 */
51
void update_movement(map_t *map, gunner_t *p, keys_t *keys, list_t *shooter_list);
52

    
53
/**
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
/**
65
 * @brief Update scale if the keys were pressed to change scale.
66
 */
67
void update_scale(void);
68

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

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

    
102

    
103

    
104
/**
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
typedef struct {
120
    /// @brief Time since construction.
121
    int time;
122
    /// @brief Text.
123
    text_t *text;
124
} text_timer_t;
125
/**
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

    
147
/**
148
 * @}
149
 */
150

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