1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:20:11 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:20:12 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
# ifndef CUB3D_H
# define CUB3D_H
#include <cub3d_defines.h>
#include <cub3d_structs.h>
#include <stddef.h>
#include <stdint.h>
#include <time.h>
/*
** ====== STRUCTS ======
*/
void ft_init_funptr(t_cub *clist);
void ft_init_ref(t_cub *clist);
int8_t ft_init_cub3d(t_cub *clist);
int ft_init_winlx(t_cub *clist);
int ft_init_winptr(t_cub *clist);
t_player ft_init_player(void);
t_ray ft_init_s_ray(void);
t_rgb ft_init_rgb(void);
int8_t ft_init_map(t_map *mlist);
t_bmp_file ft_init_bmp(void);
t_bmp_info ft_init_bmp_info(void);
t_rgb ft_hex_to_og_rgb(uint32_t color);
int8_t ft_init_sfx(t_cub *cl);
int8_t ft_init_sprites(t_sprite ***sprites);
int8_t ft_init_weaps(t_sprite ***weaps);
int8_t ft_init_bad_boys(t_cub *cl);
/*
** ====== HOOKS ======
*/
void ft_hooks_and_loops(t_win *wl, t_cub *cl);
int ft_key_event(int keycode, t_cub *clist);
int ft_key_release(int keycode, t_cub *clist);
int ft_w_key(t_cub *clist);
int ft_a_key(t_cub *clist);
int ft_s_key(t_cub *clist);
int ft_d_key(t_cub *clist);
int ft_f1_key(t_cub *clist);
int ft_left_key(t_cub *clist);
int ft_right_key(t_cub *clist);
int ft_space_key(t_cub *clist);
int ft_click_close(int keycode, t_cub *clist);
int ft_key_loop(t_cub *cl);
int32_t ft_convert_keycode(const int32_t tmp_code);
void ft_death_hooks(t_win *wl, t_cub *cl);
/*
** ====== TEXTURES ======
*/
void ft_wall_tex_init(t_cub *cl);
void ft_next_sprite_init(t_cub *cl);
void ft_weap_tex_init(t_cub *cl);
void ft_num_tex_init(t_cub *cl);
void ft_tex_bad_boy_init(t_cub *cl);
/*
** ====== DRAW ======
*/
void ft_draw_square(int a, int b, int rgb, t_cub *clist);
void ft_draw_map(char **map, t_cub *clist);
void ft_draw_texture(t_cub *cl, int x, int y, int tex_y);
int8_t ft_draw_hud(t_cub *clist);
void ft_draw_minimap_back(t_cub *cl);
void ft_draw_ammo_back(t_cub *cl);
void ft_draw_health_caption(t_cub *cl);
void ft_draw_ammo_caption(t_cub *cl);
void ft_draw_life_bar(t_cub *cl);
void ft_draw_ammo_bar(t_cub *cl);
void ft_draw_scene(t_cub *clist);
void ft_draw_scene_bmp(t_cub *clist);
void ft_draw_circle(float a, float b,
int32_t color, t_cub *cl);
void ft_draw_verline(t_cub *cl, int32_t x, int32_t y, int32_t y2);
void ft_sprite_h_w(t_cub *cl, t_sprite *sprite);
void ft_alloc_big_t(t_cub *cl);
void ft_fill_big_t(float **dist_tab, t_cub *cl);
void ft_sort_big_t(t_cub *cl);
void ft_sort_sprites(t_cub *cl, int16_t i, int16_t j);
void ft_sort_s_t(t_cub *cl, float **dist_tab);
void ft_calc_sprite(t_cub *cl);
void ft_draw_sprite(t_cub *cl, t_sprite *sprite);
void ft_calc_heal(t_cub *cl);
void ft_draw_heals(t_cub *cl, t_sprite *sprite);
void ft_calc_weaps(t_cub *cl);
void ft_draw_weapon(t_cub *cl, t_sprite *sprite);
void ft_draw_handweap(t_cub *cl);
void ft_macos_suffer_animation(uint16_t dmg, t_cub *cl);
void ft_linux_suffer_animation(uint16_t dmg, t_cub *cl);
void *ft_ammo_back_thread(void *vargp);
void *ft_minimap_back_thread(void *vargp);
void *ft_map_thread(void *vargp);
void *ft_life_bar_thread(void *vargp);
void *ft_ammo_bar_thread(void *vargp);
void *ft_health_cap_thread(void *vargp);
void *ft_ammo_cap_thread(void *vargp);
void *ft_wall_one(void *vargp);
void *ft_wall_two(void *vargp);
void *ft_wall_three(void *vargp);
void *ft_wall_four(void *vargp);
void *ft_wall_five(void *vargp);
void *ft_floor_one(void *vargp);
void *ft_floor_two(void *vargp);
void *ft_floor_three(void *vargp);
void *ft_floor_four(void *vargp);
void *ft_floor_five(void *vargp);
/*
** ====== PARSING ======
*/
void ft_parse_map(const char *map_path, t_cub *clist);
void ft_get_player_spawn(t_player *plist, t_cub *clist);
void ft_get_nlvl_pos(t_map *ml);
int8_t ft_select_get(char **words, t_cub *clist);
int8_t ft_get_screen_size(t_win *wlist);
int8_t ft_get_res(char **words, t_cub *clist);
int8_t ft_get_tex_no(char **words, t_cub *clist);
int8_t ft_get_tex_so(char **words, t_cub *clist);
int8_t ft_get_tex_ea(char **words, t_cub *clist);
int8_t ft_get_tex_we(char **words, t_cub *clist);
int8_t ft_get_sprite(char **words, t_cub *clist);
int8_t ft_get_f_color(char **words, t_cub *clist);
int8_t ft_get_f_tex(char **words, t_cub *clist);
int8_t ft_get_c_color(char **words, t_cub *clist);
int8_t ft_get_c_tex(char **words, t_cub *clist);
int8_t ft_get_darkness(char **words, t_cub *clist);
int8_t ft_get_path_nl(char **words, t_cub *clist);
int8_t ft_get_traps(char **words, t_cub *clist);
int8_t ft_get_tex_nl(char **words, t_cub *clist);
int8_t ft_get_music(char **words, t_cub *clist);
size_t ft_get_map_h(char **map);
size_t ft_get_map_w(char **map);
int8_t ft_get_next_sprite(t_cub *clist, int s_n, char c, size_t x);
void ft_get_sprite_spawn(t_cub *clist);
void ft_get_heal_spawn(t_cub *clist);
void ft_get_weapon_spawn(t_cub *clist);
int8_t ft_check_map_line(char *line, uint8_t l, t_cub *clist);
int8_t ft_check_ext(const char *filep, const char *ext);
int8_t ft_check_not_found(const char *path);
int ft_get_map_first_line(char *line, t_cub *clist);
int ft_get_map_core(int fd, t_cub *clist);
void ft_get_topsp(char c, t_cub *clist);
void ft_check_map_surrounds(t_map *ml, t_cub *cl);
int ft_check_missing(t_cub *clist);
int ft_check_missing_tex_defines(t_cub *clist);
int ft_check_missing_sfx(t_cub *clist);
size_t ft_get_line_len(char *line);
void ft_get_spawns(t_cub *cl);
/*
** ====== ERROR ======
*/
int ft_error(uint8_t retval, const char *errmsg, t_cub *clist);
int ft_missing_error(const char *err, t_cub *clist);
int ft_map_error(const char *errmsg, t_cub *clist);
int ft_alloc_error(t_cub *clist);
/*
** ====== ARGS ======
*/
uint8_t ft_check_map_arg(int argc, const char *argv[]);
uint8_t ft_use_args(int argc, const char *argv[], t_cub *clist);
/*
** ====== RAYCAST ======
*/
void ft_castray(t_cub *cl);
void ft_choose_tex(uint16_t x, t_cub *clist);
void ft_detect(t_cub *cl);
void ft_detection_init_x(t_cub *cl);
void ft_detection_init_y(t_cub *cl);
void *ft_wall_cast(void *vargp);
void *ft_floor_cast(void *vargp);
void ft_floor_cast_inits(uint16_t y, t_ray *rl, t_cub *cl);
void ft_calc_tex(t_cub *cl);
void ft_initray(uint16_t i, t_cub *cl);
void ft_castray_loop(uint16_t i, t_win *wl, t_cub *cl);
void ft_set_fc_tex_xy(uint8_t tid, uint16_t x, uint16_t y, t_cub *cl);
void ft_floor_loop(uint16_t y, t_cub *cl);
void ft_floor_cast_loop(uint16_t y, uint16_t x, t_cub *cl);
/*
** ====== SFX ======
*/
void ft_sfx_death(t_sfx *sfx);
void ft_sfx_footstep(t_sfx *sfx);
void ft_sfx_new_level(t_sfx *sfx);
void ft_sfx_pain(t_sfx *sfx);
void ft_sfx_trap(t_sfx *sfx);
void ft_sfx_heal(t_sfx *sfx);
void ft_sfx_weapon_one_load(t_sfx *sfx);
void ft_sfx_weapon_one_fire(t_sfx *sfx);
void ft_sfx_weapon_two_load(t_sfx *sfx);
void ft_sfx_weapon_two_fire(t_sfx *sfx);
void ft_sfx_weapon_two_fire_alt(t_sfx *sfx);
void ft_sfx_weapon_two_fire_alt_alt(t_sfx *sfx);
void ft_sfx_weapon_three_load(t_sfx *sfx);
void ft_sfx_weapon_three_fire(t_sfx *sfx);
void ft_sfx_ooa(t_sfx *sfx);
void ft_sfx_bb_death(t_sfx *sfx);
void ft_sfx_bb_scream(t_sfx *sfx);
void ft_sfx_bb_fire(t_sfx *sfx);
void *ft_sfx_death_thread(void *vargp);
void *ft_sfx_footstep_thread(void *vargp);
void *ft_sfx_new_lvl_thread(void *vargp);
void *ft_sfx_pain_thread(void *vargp);
void *ft_sfx_trap_thread(void *vargp);
void *ft_sfx_heal_thread(void *vargp);
void *ft_sfx_w_one_load_thread(void *vargp);
void *ft_sfx_w_one_fire_thread(void *vargp);
void *ft_sfx_w_two_load_thread(void *vargp);
void *ft_sfx_w_two_fire_thread(void *vargp);
void *ft_sfx_weapon_two_fire_thread_alt(void *vargp);
void *ft_sfx_weapon_two_fire_thread_alt_alt(void *vargp);
void *ft_sfx_weapon_three_load_thread(void *vargp);
void *ft_sfx_weapon_three_fire_thread(void *vargp);
void *ft_sfx_ooa_thread(void *vargp);
void *ft_sfx_bb_death_thread(void *vargp);
void *ft_sfx_bb_scream_thread(void *vargp);
void *ft_sfx_bb_fire_thread(void *vargp);
/*
** ====== TIMINGS ======
*/
float ft_clock_to_ms(clock_t ticks);
void ft_timings(clock_t before, t_cub *cl);
void ft_handle_firing(clock_t before, t_cub *cl);
void ft_get_fps_count(clock_t before, t_cub *cl);
/*
** ====== BAD BOYS ======
*/
void ft_select_bad_boy_action(t_cub *cl);
void ft_bb_wait(t_bad_boy *bl, t_sprite *sl, t_map *ml);
void ft_bb_walk(t_bad_boy *bl, t_sprite *sl, t_map *ml);
void ft_bb_fire(t_bad_boy *bl, t_sprite *sl, t_map *ml);
void ft_check_bad_boy_shoot(t_cub *cl);
void ft_damage_bad_boy(t_cub *cl);
int8_t ft_can_it_shoot(int8_t id, double d, t_cub *cl);
/*
** ====== DELETION ======
*/
void ft_del_tex(t_cub *clist);
void ft_del_map(t_map *ml);
void ft_del_sprites_lists(t_cub *clist);
void ft_del_sfx_cmd(t_cub *clist);
uint8_t ft_free_words(char **words);
uint8_t ft_free_sprites_path(char **sprites);
int ft_exit(uint8_t exit_code, t_cub *clist);
/*
** ====== OTHER ======
*/
void ft_set_minimap_scale(t_cub *clist);
void ft_enable_music(t_cub *cl);
int8_t ft_save_to_bmp(t_cub *cl);
int8_t ft_warp_level(char *path, t_cub *cl);
uint32_t ft_rgb_to_hex(float dist, t_rgb rgb, t_cub *cl);
t_bmp_rgb ft_hex_to_rgb(uint32_t color);
uint32_t ft_darken(t_rgb rgb, t_cub *cl);
void ft_death_screen(t_cub *cl);
void ft_find_item(t_player *pl, t_map *ml, t_cub *cl);
int8_t ft_switch_weap_one(t_cub *cl);
int8_t ft_switch_weap_two(t_cub *cl);
int8_t ft_switch_weap_three(t_cub *cl);
void ft_shoot(t_cub *cl);
int ft_handle_keys(uint8_t i, float old_y, float old_x, t_cub *cl);
# endif
|