merge bgoulard branch on master

This commit is contained in:
Baptiste GOULARD 2024-11-28 13:56:45 +01:00
commit 2568aa69a6
14 changed files with 464 additions and 78 deletions

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/30 16:30:26 by rparodi #+# #+# */
/* Updated: 2024/11/26 13:37:20 by rparodi ### ########.fr */
/* Updated: 2024/11/28 13:54:39 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
@ -32,7 +32,7 @@ void cleanup_info(t_info *info);
int c3_options(t_info *info, int argc, char *argv[]);
void c3_perror(t_info *info);
void print_error(const char *msg);
void print_error(const char *msg, int errno_state);
void parse_map(t_info *info);
void parse_args(char *arg, t_info *inf);

View file

@ -6,13 +6,14 @@
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/09 01:15:15 by bgoulard #+# #+# */
/* Updated: 2024/11/11 21:34:02 by rparodi ### ########.fr */
/* Updated: 2024/11/27 11:35:39 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CUB3D_OPTIONS_H
# define CUB3D_OPTIONS_H
void c3_set_parse_excl(void *usr_control_struct);
void c3_set_file(void *usr_control_struct, const char *arg);
void c3_set_debug(void *usr_control_struct);
void c3_set_save(void *usr_control_struct);

53
includes/cub3d_parsing.h Normal file
View file

@ -0,0 +1,53 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d_parsing.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/11 14:41:07 by bgoulard #+# #+# */
/* Updated: 2024/11/18 11:32:00 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CUB3D_PARSING_H
# define CUB3D_PARSING_H
# include <stdbool.h>
# define C3D_PRS_PLS "SO"
# define C3D_PRS_PLW "WE"
# define C3D_PRS_PLN "NO"
# define C3D_PRS_PLE "EA"
# define C3D_PRS_WLL_TRAIL ' '
# define C3D_PRS_WLL '1'
# define C3D_PRS_EMP '0'
enum e_tile_m
{
EMPTY,
DOOR_OPEN,
DOOR_ANIM,
DOOR_CLOSE,
WALL_TRAIL,
WALL,
PLAYER_N,
PLAYER_S,
PLAYER_E,
PLAYER_W
};
typedef struct s_map_truth
{
enum e_tile_m tile;
char chr[2];
} t_map_truth;
typedef struct s_tile
{
enum e_tile_m tile;
bool visited;
} t_tile;
#endif /* CUB3D_PARSING_H */

View file

@ -5,8 +5,8 @@
/* +:+ +:+ +:+ */
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/08 23:55:29 by bgoulard #+# #+# */
/* Updated: 2024/11/26 13:35:13 by rparodi ### ########.fr */
/* Created: 2024/11/28 13:53:54 by bgoulard #+# #+# */
/* Updated: 2024/11/28 13:54:53 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,6 +18,8 @@
# define FILE_EXTENSION ".cub"
# define FILE_EXTENSION_LEN 4
# define BG_CLG 0
# define BG_FLR 1
#define FOV 65
#define TILE_SIZE 64
@ -38,6 +40,14 @@ typedef struct s_color
};
} t_color;
typedef struct s_texture
{
t_img *img;
int width;
int height;
char *path;
} t_texture;
typedef struct s_point
{
int x;
@ -54,9 +64,19 @@ typedef struct s_dpoint
typedef enum e_tile
{
EMPTY,
WALL
} t_tile;
EMPTY = 0,
WALL = 1,
} t_tile_type;
typedef union u_tile
{
int raw_tile;
struct {
unsigned int tile_visited: 1; // parsing
unsigned int other: 27; // disponible
unsigned int tile_type: 4; // 16 tile types possible
};
} t_tile;
typedef struct s_map
{
@ -67,6 +87,7 @@ typedef struct s_map
t_tile *map;
char **fraw;
t_img *texture[4];
t_texture texture_[4];
t_color bg_colors[2];
} t_map;
@ -86,6 +107,7 @@ typedef struct s_cli
char *file;
bool save;
bool help;
bool no_graphics;
} t_cli;
// -- error utils
@ -103,6 +125,7 @@ typedef enum e_error
ERROR_PARSE,
ERROR_CLI,
ERROR_MLX,
ERROR_TEXTURE_FORMAT,
ERROR_IMPLEM,
} t_error;
@ -111,6 +134,8 @@ typedef enum e_error
typedef struct s_info
{
t_error last_error;
int errno_state;
t_xvar *mlx_ptr;
t_win_list *win_ptr;
t_map map;

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/30 16:43:20 by rparodi #+# #+# */
/* Updated: 2024/11/09 00:42:02 by bgoulard ### ########.fr */
/* Updated: 2024/11/27 11:57:28 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,5 +19,7 @@
# define RED "\x1b[31m"
# define BOLD_RED "\033[1;31m"
# define YELLOW "\x1b[33m"
# define BOLD_YELLOW "\033[1;33m"
# define RESET "\x1b[K\x1b[0m"
#endif