-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcub3d.h
279 lines (255 loc) · 5.86 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ccastill <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/23 06:18:44 by ccastill #+# #+# */
/* Updated: 2021/05/10 22:14:25 by ccastill ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CUB3D_H
# define CUB3D_H
# define A 97
# define W 119
# define S 115
# define D 100
# define LEFT 65361
# define RIGHT 65363
# define ESC 65307
# define ESC 65307
# define SPEED 0.08
# define X_EXIT 33
# include <X11/Xlib.h>
# include "./lib/mlx/minilibx-linux/mlx.h"
# include "./lib/libft/libft.h"
# include "./lib/get_next_line/get_next_line.h"
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
# include <fcntl.h>
# include <unistd.h>
# include <math.h>
typedef struct s_check
{
int img_save;
int res_w;
int res_h;
int count_parameters;
int param_r;
int param_no;
int param_so;
int param_we;
int param_ea;
int param_s;
int param_f;
int param_c;
char *texture_no;
char *texture_so;
char *texture_we;
char *texture_ea;
char *texture_s;
int floor_r;
int floor_g;
int floor_b;
int rgb_f;
int celing_r;
int celing_g;
int celing_b;
int rgb_c;
int n_columns;
int n_rows;
char **map;
char *buffer;
char player_ori;
int player_x;
int player_y;
int n_player;
int n_sprites;
int pathfound;
int error;
char *error_line;
} t_check;
typedef struct s_mlx
{
void *ptr;
void *win;
void *image;
int *data;
int bpp;
int size_lenght;
int endian;
} t_mlx;
typedef struct s_text_wall
{
void *p_no;
int *data_no;
int no_bpp;
int no_sl;
int no_end;
int no_h;
int no_w;
void *p_we;
int *data_we;
int we_bpp;
int we_sl;
int we_end;
int we_h;
int we_w;
void *p_so;
int *data_so;
int so_bpp;
int so_sl;
int so_end;
int so_h;
int so_w;
void *p_ea;
int *data_ea;
int ea_bpp;
int ea_sl;
int ea_end;
int ea_h;
int ea_w;
void *p_sp;
int *data_sp;
int sp_bpp;
int sp_sl;
int sp_end;
int sp_h;
int sp_w;
int txt;
double step;
double pos;
int y;
int *data;
int bpp;
int sl;
int end;
int h;
int w;
int colorc;
int colorf;
int colortx;
char wall_dir;
} t_text_wall;
typedef struct s_keys
{
int up;
int down;
int left;
int right;
int rot_l;
int rot_r;
int esc;
} t_keys;
typedef struct s_player
{
char dir_player;
double pos_x;
double pos_y;
double dir_x;
double dir_y;
double plane_x;
double plane_y;
double speed;
} t_player;
typedef struct s_sprite
{
double x;
double y;
} t_sprite;
typedef struct s_raycast
{
double camera_x;
double ray_dir_x;
double ray_dir_y;
double side_dist_x;
double side_dist_y;
double delta_dist_x;
double delta_dist_y;
double wall_dist;
double wall_x;
int step_x;
int step_y;
int x;
int map_x;
int map_y;
int hit;
int side;
int line_height;
int draw_start;
int draw_end;
} t_raycast;
typedef struct s_sprite_casting
{
double x;
double y;
double inv_det;
double transform_x;
double transform_y;
int screen_x;
int h;
int draw_start_y;
int draw_end_y;
int w;
int draw_start_x;
int draw_end_x;
int stripe;
int tex_x;
int s_y;
int d;
int tex_y;
double z_buffer[4000];
int *sprite_order;
double *sprite_distance;
} t_sprite_cas;
typedef struct s_cub
{
t_check cf;
t_mlx mlx;
t_text_wall texture;
t_player player;
t_keys k;
t_sprite *sprite;
t_sprite_cas s_cast;
t_raycast ray;
} t_cub;
void read_file(char *argv, t_cub *cub);
void extract_resolution(char *line, char *position, t_cub *cub);
char *extract_texture(char *line, char *position, t_cub *cub);
char *extract_texture_sprite(char *line, char *position,
t_cub *cub);
void extract_color_celing(char *line, char *position,
t_cub *cub);
void extract_color_floor(char *line, char *position,
t_cub *cub);
void read_map(int fd, char *line, t_cub *cub);
void read_moremap(t_cub *cub);
int get_textures(t_cub *cub);
void init_player(t_cub *cub);
int init_keys(t_cub *cub);
void init_sprites (t_cub *cub);
int key_press(int k, t_cub *cub);
int key_release(int k, t_cub *cub);
void movement(t_cub *cub, t_player *player);
int raycasting(t_cub *cub);
void paint(t_cub *cub, t_raycast *ray, int x);
void raycasting_sprite(t_cub *cub);
void set_texture(t_raycast *ray, t_player *player, t_cub *cub);
int exit_game(t_cub *cub3d);
int rgb_conver(int t, int r, int g, int b);
int check_line_before_parameter(char *position, char *line,
t_cub *cub);
int def_sprites(int n_sprites, t_cub *cub);
void screenshot(t_cub *cub);
void check_position_color(char *position, t_cub *cub);
int exit_game(t_cub *cub);
int exit_game_texture(char *str, t_cub *cub);
void free_split(char **str);
void free_print_error(char *s, t_cub *cub);
void print_error(char *s, t_cub *cub);
void print_error_arg(char *s);
void print_error_window(char *s, t_cub *cub);
void print_error_image(char *s, t_cub *cub);
#endif