-
Notifications
You must be signed in to change notification settings - Fork 1
/
cub3d.h
261 lines (250 loc) · 7.74 KB
/
cub3d.h
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: amuriel <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/26 16:57:45 by amuriel #+# #+# */
/* Updated: 2021/04/04 09:13:26 by amuriel ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CUB3D_H
# define CUB3D_H
# include "libft/libft.h"
# include "minilibx-linux/mlx.h"
# include <unistd.h>
# include <stdlib.h>
# include <fcntl.h>
# include <sys/stat.h>
# include <math.h>
# include <stdint.h>
# define ESC 65307
# define W 119
# define S 115
# define A 97
# define D 100
# define KEY_LEFT 65361
# define KEY_RIGHT 65363
# define TEX_WIDTH 64
# define TEX_HEIGHT 64
# define MOVESPEED 0.15
# define ROTSPEED 0.03
typedef struct s_data
{
void *img;
void *mlx;
void *win;
char *addr;
int bits_per_pixel;
int size_line;
int endian;
} t_data;
typedef struct s_rgb
{
int col_r;
int col_g;
int col_b;
int rgb_color;
} t_rgb;
typedef struct s_headshot
{
int fd;
int bmp_plane;
int scr_size;
int bmp_size;
int bmp_off_bits;
int zero;
int color_table;
int range;
int col;
} t_headshot;
typedef struct s_sprite
{
double x_str;
double y_str;
} t_sprite;
typedef struct s_pm
{
int fd;
char *line;
char *tmp;
char **tmp2;
int param;
int countlines;
int flag_pos_pl;
int count_lines1;
int count_lines2;
int flag_perm;
int flag_text;
int flag_color;
} t_pm;
typedef struct s_engine
{
t_data data;
t_data data_no;
t_data data_so;
t_data data_we;
t_data data_ea;
t_data data_spr;
t_sprite *str_spr;
t_rgb rgb_floor;
t_rgb rgb_ceiling;
t_headshot shot;
t_pm pm;
int screen_flag;
int scr_height;
int scr_width;
char **world_map;
int x;
int y;
double pos_x;
double pos_y;
double dir_x;
double dir_y;
double plane_x;
double plane_y;
double ray_dir_x;
double ray_dir_y;
int map_x;
int map_y;
double side_dist_x;
double side_dist_y;
double delta_dist_x;
double delta_dist_y;
int step_x;
int step_y;
int side;
int draw_start;
int draw_end;
double perp_wall_dist;
int line_height;
int keycode_w;
int keycode_s;
int keycode_a;
int keycode_d;
int keycode_left;
int keycode_right;
double old_dir_x;
double old_plane_x;
double wall_x;
int texture_x;
int texture_y;
double step;
double tex_pos;
char *tex_north;
char *tex_south;
char *tex_west;
char *tex_east;
char *tex_sprite;
double *z_buff;
int sprite_num;
int *sprite_order;
double *sprite_dist;
double tmp_dist;
double sprite_x;
double sprite_y;
double inv_det;
double transform_x;
double transform_y;
int sprite_scr_x;
int sprite_h;
int draw_start_y;
int draw_end_y;
int sprite_w;
int draw_start_x;
int draw_end_x;
int stripe;
int spr_text_x;
int spr_text_y;
int tmp_spr_y;
int tmp_spr_d;
int spr_col;
int s;
} t_engine;
void ft_mlx_data_start(t_engine *engine);
void ft_mlx_data_continue(t_engine *engine);
void ft_screenshot_start(t_engine *engine);
int ft_restart(t_engine *engine);
int ft_raycast(t_engine *engine);
void ft_all_calculation(t_engine *engine);
void ft_camera_calculation(t_engine *engine);
void ft_ray_position(t_engine *engine);
void ft_ray_hit(t_engine *engine);
void ft_ray_walldist_calculation(t_engine *engine);
void ft_ray_walldist_calculation2(t_engine *engine);
unsigned int ft_get_pixel(t_data *data, int x, int y);
void my_mlx_pixel_put(t_data *data, int x, int y, int color);
int ft_init_engine(t_engine *engine);
void ft_init_texture(t_engine *engine);
void ft_init_texture2(t_engine *engine, int width,
int height);
void ft_free_texture(t_engine *engine);
void ft_init_keycode(t_engine *engine);
int check_movement(t_engine *engine, int x, int y);
int ft_exit(t_engine *engine);
int ft_keycode_unused(int keycode, t_engine *engine);
int ft_keycode_used(int keycode, t_engine *engine);
void ft_keycode_movement_ad(t_engine *engine);
void ft_keycode_movement_rot_right(t_engine *engine);
void ft_keycode_movement_rot_left(t_engine *engine);
void ft_keycode_movement_ws(t_engine *engine);
void ft_keycode_movement(t_engine *engine);
void ft_main_sprites(t_engine *engine);
void ft_swap_sprites(t_engine *engine);
void ft_sort_swap(t_engine *engine);
void ft_sprite_calculation3(t_engine *engine);
void ft_sprite_calculation2(t_engine *engine);
void ft_sprite_calculation1(t_engine *engine);
t_sprite *ft_get_sprites(t_engine *engine);
void ft_correct_sprite(t_engine *engine);
int ft_number_sprites(t_engine *engine);
void ft_print_wall(t_engine *engine);
int ft_get_rgb_color_ceiling(t_engine *engine);
int ft_get_rgb_color_floor(t_engine *engine);
int ft_start_parse(char **argv, t_engine *engine);
int ft_correct_texture(char *line);
void ft_norm_pm3(t_engine *engine, char *line);
void ft_norm_pm1(t_engine *engine, char *line);
void ft_init_pm_start(t_engine *engine);
void ft_valid_open_map(t_engine *engine, char **argv);
void ft_correct_texture2(t_engine *engine, char *line);
void ft_norm_pm2(t_engine *engine, char *line);
void ft_correct_colors(t_engine *engine, char *line);
int ft_check_color_double(t_engine *engine);
int ft_check_texture_double(t_engine *engine);
int ft_check_scr_col_tex(t_engine *engine);
void ft_correct_permission(t_engine *engine, char *line);
void ft_parse_world_map(t_engine *engine);
void ft_check_map_player(t_engine *engine, int i, int j);
void ft_check_closed_map1(t_engine *engine, int i, int j);
void ft_check_closed_map2(t_engine *engine, int i, int j);
void ft_check_player_position1(t_engine *engine,
int i, int j);
void ft_check_player_position2(t_engine *engine,
int i, int j);
int ft_check_more_players(t_engine *engine);
int ft_arr_string_len(char **arr);
char *ft_strjoin_pm(char *s1, char *s2);
void ft_free_array(char ***arr);
void ft_print_error(char *s);
void ft_get_resolution(t_engine *engine);
int ft_check_perm_double(t_engine *engine);
int ft_isdigit_pm(char *s);
int ft_check_rgb(char *s);
void ft_get_rgb_color_c(t_engine *engine, char **var);
void ft_get_rgb_color_f(t_engine *engine, char **var);
int ft_get_rgb_color(t_engine *engine, char *line);
int ft_check_fd_texture(char *tmp2);
int ft_checker_space_tx(char *str);
int ft_get_texture_parse(t_engine *engine, char *line);
void ft_screenshot_make(t_engine *engine);
void ft_init_shot_header(t_engine *engine);
void ft_screen_pack(t_engine *engine);
void ft_pm_start_valid_open_map(t_engine *engine,
char **argv);
void ft_correct_perm_color(t_engine *engine, char *line);
int ft_check_save_argv(char **argv);
void ft_check_impossible_symbol(t_engine *engine,
char *line);
#endif