forked from titogf/cub3D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cub3D.h
188 lines (162 loc) · 3.56 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3D.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mhernang <mhernang@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/23 15:01:44 by gfernand #+# #+# */
/* Updated: 2024/04/16 17:00:00 by mhernang ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CUB3D_H
# define CUB3D_H
# include <unistd.h>
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <fcntl.h>
# include "libft.h"
# include "minilibx/mlx.h"
# define MAX 2147483647
# define MIN -2147483648
# define W_WIDTH 1200
# define W_HEIGHT 800
# define PI 3.1415926535
# define SQR_SIZE 15
# define MAP_SCALE 64
# define IMG_SCALE 32
typedef struct s_player
{
int x;
int y;
char dir;
} t_player;
typedef struct s_map
{
char **map;
int rows;
int cols;
t_player player_pos;
} t_map;
typedef struct RGB
{
int r;
int g;
int b;
} t_RGB;
typedef struct data
{
char *no;
char *so;
char *we;
char *ea;
int f;
int c;
t_map map;
} t_data;
typedef struct s_ray
{
int color;
int angle;
double radians;
int look;
int dof;
double vx;
double vy;
double rx;
double ry;
double ra;
double xo;
double yo;
double d_v;
double d_h;
double tan;
} t_ray;
typedef struct s_img
{
void *img;
char *addr;
int bits;
int line;
int end;
int w;
int h;
} t_img;
typedef struct s_draw
{
float x;
float y;
int len;
int color;
t_img texture;
} t_draw;
typedef struct s_brsh
{
int x0;
int x1;
int y0;
int y1;
int dx;
int dy;
int sx;
int sy;
} t_brsh;
typedef struct s_cub
{
void *mlx;
void *win;
t_img *img;
int height;
int width;
t_ray ray;
t_data data;
t_img no_tex;
t_img so_tex;
t_img we_tex;
t_img ea_tex;
int px;
int py;
int pa;
int map_h;
int map_w;
int mouse;
} t_cub;
void window(t_cub *cub);
void exit_mssg(char *s);
void error_msg(char *err);
/* PARSE */
void parse(char *file, t_data *data);
/* PARSE_UTILS */
void free_map(char ***map);
void set_player_pos(t_data *data);
int ft_strrncmp(char *s1, char *s2, int n);
int elements_full(t_data *data);
int is_zero(char *str);
/* PROCESS */
void process_line(char *line, t_data *data);
/* PROCESS_MAP */
void process_map(int fd, char *line, t_data *data);
/* FILL_SPACES*/
char **fill_spaces(char **original, int rows, int *cols);
/* CHECK_BORDERS*/
void check_borders(t_map *map);
/* EXECUTION */
void execution(t_data data);
void set_pixel(t_img *img, int x, int y, int color);
void bresenham_line(t_cub cub, t_brsh brsh, int color);
void map2d(t_cub cub, t_ray ray);
void throw_rays(t_cub cub, t_ray ray);
void box(t_cub cub, int x, int y, int color);
void player(t_cub cub, t_ray ray);
void walls(t_cub cub, t_ray ray);
void wasd(t_cub *cub, int key);
void vertical(t_cub cub, t_ray *ray);
void horizontal(t_cub cub, t_ray *ray);
t_img side_texture(t_cub cub, t_ray *ray, float w, int i);
t_img new_texture(t_cub *cub, char *path);
void init_textures(t_data *data, t_cub *cub);
int get_color_from_image(t_img *img, int x, int y);
//gnl
char *get_next_line(int fd);
#endif