Cub3D
 
Loading...
Searching...
No Matches
data_structure.h
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* data_structure.h :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: ppontet <ppontet@student.42lyon.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/06/15 11:28:00 by ppontet #+# #+# */
9/* Updated: 2025/09/30 17:40:47 by ppontet ### ########lyon.fr */
10/* */
11/* ************************************************************************** */
12
13#ifndef DATA_STRUCTURE_H
14# define DATA_STRUCTURE_H
15
21
22# include <endian.h>
23# include <stdbool.h>
24# include <stddef.h>
25
26typedef struct s_img t_img;
27typedef struct s_textures t_textures;
29typedef struct s_mlx t_mlx;
30typedef struct s_map t_map;
31typedef struct s_map_raoul t_map_raoul;
32typedef struct s_data t_data;
33typedef struct s_settings t_settings;
34
36typedef struct s_pos2 t_pos2;
37typedef struct s_vec2 t_vec2;
38
39typedef struct s_args t_args;
40typedef union u_color t_color;
41typedef struct s_raydata t_raydata;
42typedef struct s_input t_input;
43typedef struct s_player t_player;
44
61
62# if __BYTE_ORDER == __BIG_ENDIAN
63
71{
72 int argb;
73 struct __attribute__((packed))
74 {
75 unsigned char alpha;
76 unsigned char red;
77 unsigned char green;
78 unsigned char blue;
79 };
80};
81
82# else
83
90union u_color
91{
92 int argb;
93 struct __attribute__((packed))
94 {
95 unsigned char blue;
96 unsigned char green;
97 unsigned char red;
98 unsigned char alpha;
99 };
100};
101# endif
102
108struct s_img
109{
110 char *path;
111 char *pxls;
112 void *img;
113 /* 4 bytes padding here : char padding[4];*/
114 int width;
119};
120
136
142{
143 size_t x;
144 size_t y;
145};
146
151struct s_pos2
152{
153 int x;
154 int y;
155};
156
161struct s_vec2
162{
163 float x;
164 float y;
165};
166
186
192{
194 float angle;
195 float fov;
196};
197
210
227
242
261
273
293
307
312struct s_args
313{
314 char *map;
315 char *gen;
316 int goal;
317 char *key_tex;
318 char *door_tex;
319};
320
321#endif
struct s_spritedata t_spritedata
Definition data_structure.h:28
struct s_data t_data
Definition data_structure.h:32
struct s_vec2 t_vec2
Definition data_structure.h:37
struct s_pos2 t_pos2
Definition data_structure.h:36
e_screen_size
Enum used to store the screen size. It is used to set the screen size in the settings....
Definition data_structure.h:52
@ SIZE_480P
Definition data_structure.h:59
@ SIZE_4K
Definition data_structure.h:55
@ SIZE_2K
Definition data_structure.h:56
@ SIZE_1080P
Definition data_structure.h:57
@ SIZE_NONE
Definition data_structure.h:53
@ SIZE_720P
Definition data_structure.h:58
@ SIZE_FULL_SCREEN
Definition data_structure.h:54
struct s_settings t_settings
Definition data_structure.h:33
struct s_map_raoul t_map_raoul
Definition data_structure.h:31
struct s_raydata t_raydata
Definition data_structure.h:41
struct s_args t_args
Definition data_structure.h:39
struct s_img t_img
Definition data_structure.h:26
struct s_input t_input
Definition data_structure.h:42
struct s_mlx t_mlx
Definition data_structure.h:29
struct s_map t_map
Definition data_structure.h:30
struct s_textures t_textures
Definition data_structure.h:27
struct s_player t_player
Definition data_structure.h:43
union u_color t_color
Definition data_structure.h:40
struct s_coordinates t_coordinates
Definition data_structure.h:35
Structure to handle command-line arguments.
Definition data_structure.h:313
char * gen
Definition data_structure.h:315
char * door_tex
Definition data_structure.h:318
char * key_tex
Definition data_structure.h:317
int goal
Definition data_structure.h:316
char * map
Definition data_structure.h:314
Structure used to store the coordinates (positive only).
Definition data_structure.h:142
size_t y
Definition data_structure.h:144
size_t x
Definition data_structure.h:143
Structure used to store the mlx and map structures.
Definition data_structure.h:267
t_player player
Definition data_structure.h:271
t_input input
Definition data_structure.h:270
t_mlx mlx
Definition data_structure.h:268
t_map map
Definition data_structure.h:269
Structure used to store an image (buffer that contain image, and size).
Definition data_structure.h:109
int mlx_width
Definition data_structure.h:115
int bits_per_pixel
Definition data_structure.h:117
int endian
Definition data_structure.h:118
char * path
Definition data_structure.h:110
int width
Definition data_structure.h:114
void * img
Definition data_structure.h:112
int height
Definition data_structure.h:116
char * pxls
Definition data_structure.h:111
Structure that handle the input of the player.
Definition data_structure.h:172
bool left
Definition data_structure.h:175
bool turn_right
Definition data_structure.h:178
int skip_next_mouse_input
Definition data_structure.h:183
bool bckwd
Definition data_structure.h:174
bool right
Definition data_structure.h:176
bool fov
Definition data_structure.h:181
bool minimap
Definition data_structure.h:180
bool turn_left
Definition data_structure.h:177
bool fwd
Definition data_structure.h:173
int delta_mouse_x
Definition data_structure.h:184
int mouse_input
Definition data_structure.h:182
bool collision
Definition data_structure.h:179
Structure to handle the special map needed for rendering.
Definition data_structure.h:233
int * walls
Definition data_structure.h:234
size_t width
Definition data_structure.h:235
t_pos2 start_pos
Definition data_structure.h:237
float start_angle
Definition data_structure.h:238
size_t height
Definition data_structure.h:236
t_pos2 door
Definition data_structure.h:240
t_pos2 key
Definition data_structure.h:239
Structure that handle the map informations.
Definition data_structure.h:248
t_coordinates exit
Definition data_structure.h:256
t_map_raoul * map
Definition data_structure.h:252
char ** map_2d
Definition data_structure.h:251
t_textures textures
Definition data_structure.h:257
size_t file_nb_lines
Definition data_structure.h:250
char ** file
Definition data_structure.h:249
int error
Definition data_structure.h:254
t_textures alt_textures
Definition data_structure.h:259
size_t number_of_moves
Definition data_structure.h:255
bool is_alt_textures
Definition data_structure.h:258
char * config[6]
Definition data_structure.h:253
Structure that handle the mlx instance.
Definition data_structure.h:216
void * win_ptr
Definition data_structure.h:218
t_pos2 win_size
Definition data_structure.h:222
t_settings settings
Definition data_structure.h:219
t_img backbuffer
Definition data_structure.h:224
t_pos2 minimap_size
Definition data_structure.h:223
float * z_buffer
Definition data_structure.h:225
int mouse_y
Definition data_structure.h:221
int mouse_x
Definition data_structure.h:220
void * mlx_ptr
Definition data_structure.h:217
Structure that handle the player information.
Definition data_structure.h:192
float angle
Definition data_structure.h:194
t_vec2 pos
Definition data_structure.h:193
float fov
Definition data_structure.h:195
Structure that handle positions in the map. Same as t_coordinates but with signed integers.
Definition data_structure.h:152
int y
Definition data_structure.h:154
int x
Definition data_structure.h:153
Structure used to store the raycasting data. It contains all the information needed to cast a ray.
Definition data_structure.h:280
int floor_color
Definition data_structure.h:291
int hit_side
Definition data_structure.h:289
t_pos2 map
Definition data_structure.h:286
int hit_wall
Definition data_structure.h:288
t_vec2 delta_dist
Definition data_structure.h:283
t_vec2 ray_dir
Definition data_structure.h:281
t_vec2 plane
Definition data_structure.h:285
t_vec2 pos
Definition data_structure.h:284
int ceil_color
Definition data_structure.h:290
t_pos2 step
Definition data_structure.h:287
t_vec2 side_dist
Definition data_structure.h:282
Structure that handle the settings of the game.
Definition data_structure.h:203
void * win_ptr
Definition data_structure.h:204
t_img background
Definition data_structure.h:206
enum e_screen_size state
Definition data_structure.h:205
t_img circle_no
Definition data_structure.h:208
t_img circle_yes
Definition data_structure.h:207
Norm-compliant multi-variable holder for math stuff.
Definition data_structure.h:298
t_raydata * rdata
Definition data_structure.h:305
int sprite_screen_x
Definition data_structure.h:302
t_pos2 draw_end
Definition data_structure.h:304
t_vec2 sprite
Definition data_structure.h:300
t_pos2 draw_start
Definition data_structure.h:303
t_pos2 sprite_size
Definition data_structure.h:301
t_vec2 transform
Definition data_structure.h:299
Structure that handle the textures of the game.
Definition data_structure.h:126
t_img door
Definition data_structure.h:131
t_color floor
Definition data_structure.h:133
t_img key
Definition data_structure.h:132
t_img south
Definition data_structure.h:130
t_color ceiling
Definition data_structure.h:134
t_img east
Definition data_structure.h:128
t_img north
Definition data_structure.h:127
t_img west
Definition data_structure.h:129
Structure that handle vector coordinates in 2D space.
Definition data_structure.h:162
float y
Definition data_structure.h:164
float x
Definition data_structure.h:163
Union used to store color information. It can be used to store color in RGBA format or as a separate ...
Definition data_structure.h:71
int argb
Definition data_structure.h:72
struct __attribute__((packed))
Definition data_structure.h:73