-
Notifications
You must be signed in to change notification settings - Fork 0
/
cub3d.h
285 lines (275 loc) · 7.98 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
280
281
282
283
284
285
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lucisanc <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/05/13 22:12:09 by lucisanc #+# #+# */
/* Updated: 2021/02/27 09:25:17 by lucisanc ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CUB3D_H
# define CUB3D_H
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
# include <time.h>
# include <fcntl.h>
# include <math.h>
# include <mlx.h>
# if defined(__APPLE__) && defined(__MACH__)
# define ADVANCE 13
# define BACK 1
# define RIGHT 2
# define LEFT 0
# define ROT_RIGHT 124
# define ROT_LEFT 123
# define ESC 53
# define RED_BUTTON 79
# define CLOSERED 17
# else
# define ADVANCE 119
# define BACK 115
# define RIGHT 100
# define LEFT 97
# define ROT_RIGHT 65363
# define ROT_LEFT 65361
# define ESC 65307
# define RED_BUTTON 79
# define CLOSERED 33
# endif
typedef struct s_xy1
{
int x;
int y;
} t_xy1;
typedef struct s_ray
{
double x;
double y;
} t_ray;
typedef struct s_display
{
double stepdraw;
double texpos;
int texxwall;
int texywall;
int indexdey;
int indexdex;
double onspritex;
double onspritey;
double invdet;
double transformx;
double transformy;
int spritescreenx;
int spriteheight;
int spritewidth;
int drawstarty;
unsigned int colorsprite;
int drawendy;
int drawstartx;
int drawendx;
int stripe;
int texx;
int texy;
int y;
int dsprite;
int spritenumber;
int cellx;
int celly;
int txfloor;
int tyfloor;
int txfloor2;
int tyfloor2;
float raydirx0;
float raydiry0;
float raydirx1;
float raydiry1;
float rowdistance;
float posz;
int initsuccess;
int maptofree;
int keyboard[100000];
int index;
int bpp;
int bpp2[11];
int s_line;
int s_line2[11];
int ed2[11];
int ed;
int startline;
int endline;
int side;
double *zbuffer;
char **map;
char *pxl;
char *spritenum;
char *north;
char *south;
char *west;
char *east;
char *spritepwd;
void *mlx_ptr;
void *mlx_win;
void *img;
int r1;
int errorbool;
int spritecounted;
int r2;
int fd;
double stepx;
double stepy;
double camerax;
double rotspeed;
double dirx;
double wallx;
double diry;
double planex;
double planey;
int lineheight;
double perwalldist;
double pspeed;
int mapx;
int bmp;
int mapy;
int *spritex;
int *spritey;
double *spritedist;
int numberofplayer;
int widthtext[11];
int heighttext[11];
void *text_no;
void *text_so;
char *filename;
int mapboleen;
void *text_we;
void *text_ea;
void *sprite;
int textnum;
char *ptr[11];
clock_t last_frame;
clock_t next_frame;
unsigned int color;
unsigned int rgbfloor[3];
unsigned int rgbceiling[3];
unsigned int rgbtemp[3];
t_ray player;
t_ray d;
t_ray deltadist;
t_ray sidedist;
t_xy1 mapi;
} t_display;
typedef struct s_bmp_header
{
int file_size;
int reserved;
int offset;
int head_size;
int width;
int height;
short planes;
short bpp;
int compression;
int img_size;
int x_res;
int y_res;
int color_palette;
int color_prio;
} t_bmp_h;
typedef struct s_parse
{
int r1;
int r2;
char **map;
t_xy1 sizemap;
} t_parse;
int parse(int argc, char *str, \
t_parse *parse, t_display *display);
int stocktextures_we(char *line, t_display *display);
int stocktextures_so(char *line, t_display *display);
int checkaround(int mapx, int mapy, t_display *display);
int stocktextures_ea(char *line, t_display *display);
int stocktextures_no(char *line, t_display *display);
int stocktextures_s(char *line, t_display *display);
void printsprite(t_display *display);
int opendoor(t_display *display);
void getxandyofsprite(t_display *display);
int getverticaldata(t_display *display, int y);
int gethorizontaldata(t_display *display);
int checkaround(int mapx, int mapy, t_display *display);
int switchspriteforsort(t_display *display, int index);
void rotation(int i, t_display *display);
int freemap(t_display *display);
int ft_expose(t_display *display);
int checkifgood2(char c);
void checksizetext(t_display *display);
void getinfowalltext(t_display *display, int x);
int findtexturenum(t_display *display);
void loadtexturesbonus(t_display *display);
void getinfosprite(t_display *display, int sprites);
int key_loop(t_display *display);
void checkkeybonus(t_display *display);
int checkcubextension(char *str, t_display *display);
void countsprite(t_display *display);
void loadtextures(t_display *display);
void *ft_memcpy(void *dest, const void *src, size_t n);
void clear_img_buffer(t_display *display);
int checkparse(t_display *display, t_parse *parse, int fd);
int freeandexit(t_display *display);
int gotomap(t_display *display, t_parse *parse, \
int len, int fd);
int write_bmp_image(t_display *display, int fd);
void *draw_image(t_display *display);
t_bmp_h set_bmp_header(t_display *display);
int put_pxl(t_display *display, int x, int y, unsigned int c);
int create_bmp(t_display *display);
int stockresolution(char *line, \
t_parse *parse, t_display *display);
int stockcolorf(char *line, t_display *display);
int stockcolorc(char *line, t_display *display);
void drawloop(t_display *display, int y, int x);
int replacecharinmap(t_display *display, \
char *line, int i, int len);
int draw_line(t_display *display, int x);
void getxy2(t_parse *parse, int b, char *line, int fd);
int stockmap(t_parse *parse, t_display *display);
void getxymap(t_parse *parse, char *filename);
int strlentoend(char *str);
int isend(char *line);
int closebyredbutton(t_display *display);
int mallocmap(t_parse *parse, t_display *display);
int raycasting(t_display *display);
int ft_keyboard(t_display *display);
int ft_key_hit(int keycode, t_display *display);
int sortmap(t_parse *parse, char *line, \
int len, t_display *display);
int display(t_parse *parse, t_display *display);
int sendrayon(t_display *display);
int showerror(t_display *display, char *str);
int ft_key_release(int keycode, t_display *display);
int showraster(t_display *display);
int searchcomma(char *line);
int initparse(t_display *display);
void initdisplay(t_display *display, t_parse *parse);
int moveplayer(int nb, t_display *display);
int findwall(t_display *display);
void sortsprites(t_display *display);
unsigned int colortoint(unsigned int r, unsigned int g, unsigned int b);
int moveornot(t_display *display, double tmpx, double tmpy);
char initposplayer(char pos, int x, int y, t_display *display);
int newwindow(t_display *display);
int floodandfill(t_display *display, int mapy, int mapx);
int drawfloor(t_display *display);
int checkthewall(t_display *display);
int get_next_line(int fd, char **line);
int ft_atoi(const char *str);
char *ft_strcpy(char *dest, char *src);
void showsprite(t_display *display);
int is_space(char c);
int ft_strlenght(char *str);
int numberblank(char *str);
void loadsprites(t_display *display);
int parseline(char *line, t_parse *parse, t_display *display);
int cmp(char *s1, char *s2, size_t n);
#endif