Last development push
This commit is contained in:
216
includes/cub3d.h
216
includes/cub3d.h
@@ -6,7 +6,7 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/11/25 19:47:02 by aortigos #+# #+# */
|
||||
/* Updated: 2025/12/09 18:40:30 by aortigos ### ########.fr */
|
||||
/* Updated: 2025/12/09 18:49:27 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -16,83 +16,201 @@
|
||||
|
||||
# include <unistd.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <math.h>
|
||||
# include <fcntl.h>
|
||||
# include <signal.h>
|
||||
# include "../lib/mlx/include/MLX42/MLX42.h"
|
||||
# include "../lib/libft/libft.h"
|
||||
# include "../lib/ft_printf/ft_printf.h"
|
||||
# include "../lib/gnl/get_next_line.h"
|
||||
|
||||
# define S_W 800
|
||||
# define S_H 600
|
||||
# define FOV 60
|
||||
# define PLAYER_SPEED 3
|
||||
/*═══════════════════════════ [ MACROS ] ═══════════════════════════════════*/
|
||||
|
||||
// MLX - GAME
|
||||
|
||||
# define S_W 1900 // screen width
|
||||
# define S_H 1000 // screen height
|
||||
# define WALL_SIZE 30 // wall size
|
||||
# define FOV 60 // field of view
|
||||
# define ROTATION_SPEED 0.045 // rotation speed
|
||||
# define PLAYER_SPEED 4 // player speed
|
||||
|
||||
// ERROR
|
||||
|
||||
# define ERR_INV_COP "Error: invalid argument\n"
|
||||
# define ERR_INV_FILE "Error: invalid file\n"
|
||||
# define ERR_EMPTY_FILE "Error: empty file\n"
|
||||
|
||||
# define ERR_MAP_INV "Error: invalid map element\n"
|
||||
# define ERR_MAP_EMPTY "Error: empty ligne in the map\n"
|
||||
# define ERR_MAP_DUP "Error: duplicate map element\n"
|
||||
# define ERR_MAP_RGB "Error: invalid color map [RGB]\n"
|
||||
|
||||
/*══════════════════════════ [ STRUCTS ] ═══════════════════════════════════*/
|
||||
|
||||
typedef struct s_tex
|
||||
{
|
||||
mlx_texture_t *no;
|
||||
mlx_texture_t *so;
|
||||
mlx_texture_t *we;
|
||||
mlx_texture_t *ea;
|
||||
} t_tex;
|
||||
|
||||
typedef struct s_turelist
|
||||
{
|
||||
char *name;
|
||||
char *value;
|
||||
struct s_turelist *next;
|
||||
} t_turelist;
|
||||
|
||||
typedef struct s_player
|
||||
{
|
||||
int plyr_x; // player x position in pixels
|
||||
int plyr_y; // player y position in pixels
|
||||
double angle; // player angle
|
||||
float fov_rd; // field of view in radians
|
||||
int rot; // rotation flag
|
||||
int l_r; // left right flag
|
||||
int u_d; // up down flag
|
||||
} t_player;
|
||||
|
||||
typedef struct s_ray
|
||||
{
|
||||
int index;
|
||||
double ray_ngl;
|
||||
double horiz_x;
|
||||
double horiz_y;
|
||||
double vert_x;
|
||||
double vert_y;
|
||||
double distance;
|
||||
int flag;
|
||||
} t_ray;
|
||||
|
||||
typedef struct s_data
|
||||
{
|
||||
int p_x; // player x position in the map
|
||||
int p_y; // player y position in the map
|
||||
int w_map; // map width
|
||||
int h_map; // map height
|
||||
int fd;
|
||||
char *line;
|
||||
char *ture;
|
||||
char **ture2d;
|
||||
char *map;
|
||||
char **map2d;
|
||||
char **sq_map;
|
||||
char **cc;
|
||||
char **ff;
|
||||
t_turelist *t_list;
|
||||
} t_data;
|
||||
|
||||
typedef struct s_mlx
|
||||
{
|
||||
mlx_image_t *img; // the image
|
||||
mlx_t *mlx_ptr; // the mlx pointer
|
||||
t_ray *ray; // the ray structure
|
||||
t_data *dt; // the data structure
|
||||
t_player *ply; // the player structure
|
||||
t_tex *tex;
|
||||
t_turelist *l_ture;
|
||||
} t_mlx;
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
// parsing.c
|
||||
int read_map(char *av, t_data *map, int *count);
|
||||
void get_x_y_player(t_data *data);
|
||||
int check_extension_map(char *file);
|
||||
int parsing(int ac, char **av, t_data *data);
|
||||
int read_map(char *av, t_data *map, int *count);
|
||||
void get_x_y_player(t_data *data);
|
||||
int check_extension_map(char *file);
|
||||
int parsing(int ac, char **av, t_data *data);
|
||||
|
||||
// frees.c
|
||||
void freetl(char *ture, char *line, int fd);
|
||||
void free_map(t_data *data);
|
||||
void free_m(t_mlx *mlx);
|
||||
void freelist(t_turelist **txture);
|
||||
void freetl(char *ture, char *line, int fd);
|
||||
void free_map(t_data *data);
|
||||
void free_m(t_mlx *mlx);
|
||||
void freelist(t_turelist **txture);
|
||||
|
||||
// lst_textures.c
|
||||
int get_index(char *line, int i);
|
||||
t_turelist *new_texture(char *line);
|
||||
void lst_back_ture(t_turelist **l_ture, t_turelist *new);
|
||||
int lst_ture(t_data *m, t_turelist **l_ture);
|
||||
int get_index(char *line, int i);
|
||||
t_turelist *new_texture(char *line);
|
||||
void lst_back_ture(t_turelist **l_ture, t_turelist *new);
|
||||
int lst_ture(t_data *m, t_turelist **l_ture);
|
||||
|
||||
// read_map.c
|
||||
int is_surrounded(char *line);
|
||||
int is_validmap(char *line, int *flag);
|
||||
char *getmap(t_data *map);
|
||||
int read_map_(t_data *map, int count);
|
||||
void process_map(t_data *map, int *count);
|
||||
int is_surrounded(char *line);
|
||||
int is_validmap(char *line, int *flag);
|
||||
char *getmap(t_data *map);
|
||||
int read_map_(t_data *map, int count);
|
||||
void process_map(t_data *map, int *count);
|
||||
|
||||
// read_map_utils.c
|
||||
int check_tures_space_tab(char **ture2d, int count);
|
||||
int parse_rgb(char **ture2d);
|
||||
int check_dup(t_data *m);
|
||||
int check_first_last_line(char **map);
|
||||
int surrounded_by_one(char **map);
|
||||
int check_tures_space_tab(char **ture2d, int count);
|
||||
int parse_rgb(char **ture2d);
|
||||
int check_dup(t_data *m);
|
||||
int check_first_last_line(char **map);
|
||||
int surrounded_by_one(char **map);
|
||||
|
||||
// textures.c
|
||||
int check_color_values(char **rgb);
|
||||
void ft_process_rgb_color(t_turelist *tmp, t_data *m);
|
||||
int color_ture(t_data *m, t_turelist *l_ture);
|
||||
int check_color_textures(char *line);
|
||||
int check_count_textures(t_data *m, int count);
|
||||
int check_color_values(char **rgb);
|
||||
void ft_process_rgb_color(t_turelist *tmp, t_data *m);
|
||||
int color_ture(t_data *m, t_turelist *l_ture);
|
||||
int check_color_textures(char *line);
|
||||
int check_count_textures(t_data *m, int count);
|
||||
|
||||
// textures_utils.c
|
||||
int is_valid_texture(char *line);
|
||||
int count_comma(char *rgb);
|
||||
int check_pos_cf(char *l);
|
||||
int line_around_one(char *line);
|
||||
char *getlastline(char **map);
|
||||
int is_valid_texture(char *line);
|
||||
int count_comma(char *rgb);
|
||||
int check_pos_cf(char *l);
|
||||
int line_around_one(char *line);
|
||||
char *getlastline(char **map);
|
||||
|
||||
//valid_map.c
|
||||
int h_map(char **map);
|
||||
int v_map(char **map);
|
||||
char *fixline(char *line, int maxlen);
|
||||
int getsize_line(char **map);
|
||||
int valid_map(t_data *m);
|
||||
int h_map(char **map);
|
||||
int v_map(char **map);
|
||||
char *fixline(char *line, int maxlen);
|
||||
int getsize_line(char **map);
|
||||
int valid_map(t_data *m);
|
||||
|
||||
// frees.c
|
||||
void ft_delete_texture(t_texture *texture);
|
||||
void ft_exit(t_mlx *mlx);
|
||||
void ft_delete_texture(t_tex *texture);
|
||||
void ft_exit(t_mlx *mlx);
|
||||
|
||||
// movement.c
|
||||
void rotate_player(t_mlx *mlx, int i);
|
||||
void move_player(t_mlx *mlx, double move_x, double move_y);
|
||||
void cub_hook(t_mlx *mlx, double move_x, double move_y);
|
||||
void ft_reset_move(mlx_key_data_t keydata, t_mlx *mlx);
|
||||
void key_press(mlx_key_data_t keydata, void *ml);
|
||||
void rotate_player(t_mlx *mlx, int i);
|
||||
void move_player(t_mlx *mlx, double move_x, double move_y);
|
||||
void cub_hook(t_mlx *mlx, double move_x, double move_y);
|
||||
void ft_reset_move(mlx_key_data_t keydata, t_mlx *mlx);
|
||||
void key_press(mlx_key_data_t keydata, void *ml);
|
||||
|
||||
// raycasting.c
|
||||
int inter_check(float angle, float *inter, float *step, int is_horizon);
|
||||
int wall_hit(float x, float y, t_mlx *mlx);
|
||||
float get_h_inter(t_mlx *mlx, float angl);
|
||||
float get_v_inter(t_mlx *mlx, float angl);
|
||||
void cast_rays(t_mlx *mlx);
|
||||
|
||||
// render.c
|
||||
void draw_floor_ceiling(t_mlx *mlx, int ray, int t_pix, int b_pix);
|
||||
mlx_texture_t *get_texture(t_mlx *mlx, int flag);
|
||||
double get_x_o(mlx_texture_t *texture, t_mlx *mlx);
|
||||
void draw_wall(t_mlx *mlx, int t_pix, int b_pix, double wall_h);
|
||||
void render_wall(t_mlx *mlx, int ray);
|
||||
|
||||
// render2.c
|
||||
int get_rgba(int r, int g, int b, int a);
|
||||
int reverse_bytes(int c);
|
||||
void my_mlx_pixel_put(t_mlx *mlx, int x, int y, int color);
|
||||
float nor_angle(float angle);
|
||||
int unit_circle(float angle, char c);
|
||||
|
||||
// execution.c
|
||||
void drow_map_pixel(void *mlxl);
|
||||
int check_load_ture(t_turelist *list);
|
||||
int load_texture(t_tex *tex, t_turelist *l_ture);
|
||||
void get_angle(t_mlx *mlx);
|
||||
int execution(t_data *dt);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user