Last development push
This commit is contained in:
2
Makefile
2
Makefile
@@ -12,7 +12,7 @@ GNL := ./lib/gnl
|
|||||||
GNL_A := ./lib/gnl/get_next_line.a
|
GNL_A := ./lib/gnl/get_next_line.a
|
||||||
|
|
||||||
HEADERS := -I ./include -I $(LIBMLX)/include -I $(LIBFT) -I $(FTPRINTF) -I $(GNL)
|
HEADERS := -I ./include -I $(LIBMLX)/include -I $(LIBFT) -I $(FTPRINTF) -I $(GNL)
|
||||||
LIBS := $(LIBMLX)/build/libmlx42.a $(LIBFT_A) $(FT_PRINTF_A) $(GNL_A) -ldl -lglfw -pthread -lm
|
LIBS := $(LIBMLX)/build/libmlx42.a $(GNL_A) $(LIBFT_A) $(FT_PRINTF_A) -ldl -lglfw -pthread -lm
|
||||||
SRCS := $(shell find ./src -iname "*.c")
|
SRCS := $(shell find ./src -iname "*.c")
|
||||||
OBJS := ${SRCS:.c=.o}
|
OBJS := ${SRCS:.c=.o}
|
||||||
|
|
||||||
|
|||||||
22
assets/maps/map.cub
Normal file
22
assets/maps/map.cub
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
NO assets/textures/backRoom.png
|
||||||
|
SO assets/textures/backRoom.png
|
||||||
|
WE assets/textures/backRoom2.png
|
||||||
|
EA assets/textures/backRoom2.png
|
||||||
|
|
||||||
|
C 164,157,79
|
||||||
|
F 136,123,55
|
||||||
|
|
||||||
|
11111111111111111111111111111
|
||||||
|
10000000001100000000000000001
|
||||||
|
10110000011100000010000010001
|
||||||
|
10010000000000000000000010001
|
||||||
|
10110000011100000010000010001
|
||||||
|
10000000001100000111011110001
|
||||||
|
11110111111111011100000010001
|
||||||
|
11110111111111011101010010001
|
||||||
|
11000000110101011100000010001
|
||||||
|
10000000000000001100000010001
|
||||||
|
10000000000000001101010010001
|
||||||
|
11000000110101011111011110N01
|
||||||
|
11110111111101011111000000001
|
||||||
|
11111111111111111111111111111
|
||||||
BIN
assets/textures/backRoom.png
Normal file
BIN
assets/textures/backRoom.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
BIN
assets/textures/backRoom2.png
Normal file
BIN
assets/textures/backRoom2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 366 KiB |
BIN
assets/textures/img_ea.png
Normal file
BIN
assets/textures/img_ea.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 673 KiB |
BIN
assets/textures/img_no.png
Normal file
BIN
assets/textures/img_no.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1002 KiB |
BIN
assets/textures/img_so.png
Normal file
BIN
assets/textures/img_so.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 920 KiB |
BIN
assets/textures/img_we.png
Normal file
BIN
assets/textures/img_we.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 861 KiB |
130
includes/cub3d.h
130
includes/cub3d.h
@@ -6,7 +6,7 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/11/25 19:47:02 by aortigos #+# #+# */
|
/* 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,16 +16,105 @@
|
|||||||
|
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
|
# include <stdio.h>
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
# include <signal.h>
|
||||||
# include "../lib/mlx/include/MLX42/MLX42.h"
|
# include "../lib/mlx/include/MLX42/MLX42.h"
|
||||||
# include "../lib/libft/libft.h"
|
# include "../lib/libft/libft.h"
|
||||||
# include "../lib/ft_printf/ft_printf.h"
|
# include "../lib/ft_printf/ft_printf.h"
|
||||||
# include "../lib/gnl/get_next_line.h"
|
# include "../lib/gnl/get_next_line.h"
|
||||||
|
|
||||||
# define S_W 800
|
/*═══════════════════════════ [ MACROS ] ═══════════════════════════════════*/
|
||||||
# define S_H 600
|
|
||||||
# define FOV 60
|
// MLX - GAME
|
||||||
# define PLAYER_SPEED 3
|
|
||||||
|
# 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
|
// Functions
|
||||||
@@ -84,7 +173,7 @@ int getsize_line(char **map);
|
|||||||
int valid_map(t_data *m);
|
int valid_map(t_data *m);
|
||||||
|
|
||||||
// frees.c
|
// frees.c
|
||||||
void ft_delete_texture(t_texture *texture);
|
void ft_delete_texture(t_tex *texture);
|
||||||
void ft_exit(t_mlx *mlx);
|
void ft_exit(t_mlx *mlx);
|
||||||
|
|
||||||
// movement.c
|
// movement.c
|
||||||
@@ -94,5 +183,34 @@ 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 ft_reset_move(mlx_key_data_t keydata, t_mlx *mlx);
|
||||||
void key_press(mlx_key_data_t keydata, void *ml);
|
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
|
#endif
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* get_next_line.c :+: :+: :+: */
|
/* get_next_line.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/15 18:37:44 by aortigos #+# #+# */
|
/* Created: 2024/03/15 18:37:44 by aortigos #+# #+# */
|
||||||
/* Updated: 2024/03/15 19:31:56 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:21:50 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -31,6 +31,8 @@ char *ft_read_to_left_str(int fd, char *left_str)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
buff[rd_bytes] = '\0';
|
buff[rd_bytes] = '\0';
|
||||||
|
if (!left_str)
|
||||||
|
left_str = ft_strdup(""); // o malloc(1) + '\0'
|
||||||
left_str = ft_strjoin(left_str, buff);
|
left_str = ft_strjoin(left_str, buff);
|
||||||
}
|
}
|
||||||
free(buff);
|
free(buff);
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strchr.c :+: :+: :+: */
|
/* ft_strchr.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/09/21 17:16:15 by aortigos #+# #+# */
|
/* Created: 2023/09/21 17:16:15 by aortigos #+# #+# */
|
||||||
/* Updated: 2023/10/12 15:15:10 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:12:12 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -16,6 +16,8 @@ char *ft_strchr(const char *str, int c)
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
if (!str)
|
||||||
|
return (NULL);
|
||||||
i = 0;
|
i = 0;
|
||||||
while (str[i] != '\0')
|
while (str[i] != '\0')
|
||||||
{
|
{
|
||||||
|
|||||||
116
src/execution/execution.c
Normal file
116
src/execution/execution.c
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* execution.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/12/09 18:46:27 by aortigos #+# #+# */
|
||||||
|
/* Updated: 2025/12/09 19:56:57 by aortigos ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../../includes/cub3d.h"
|
||||||
|
|
||||||
|
void drow_map_pixel(void *mlxl)
|
||||||
|
{
|
||||||
|
t_mlx *mlx;
|
||||||
|
|
||||||
|
mlx = mlxl;
|
||||||
|
mlx_delete_image(mlx->mlx_ptr, mlx->img);
|
||||||
|
mlx->img = mlx_new_image(mlx->mlx_ptr, S_W, S_H);
|
||||||
|
cub_hook(mlx, 0, 0);
|
||||||
|
cast_rays(mlx);
|
||||||
|
mlx_image_to_window(mlx->mlx_ptr, mlx->img, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int check_load_ture(t_turelist *list)
|
||||||
|
{
|
||||||
|
t_turelist *tmp;
|
||||||
|
mlx_texture_t *texture;
|
||||||
|
|
||||||
|
tmp = list;
|
||||||
|
while (tmp)
|
||||||
|
{
|
||||||
|
if (tmp->name && (
|
||||||
|
!ft_strncmp(tmp->name, "NO", 2)
|
||||||
|
|| !ft_strncmp(tmp->name, "SO", 2)
|
||||||
|
|| !ft_strncmp(tmp->name, "WE", 2)
|
||||||
|
|| !ft_strncmp(tmp->name, "EA", 2)))
|
||||||
|
{
|
||||||
|
texture = mlx_load_png(tmp->value);
|
||||||
|
if (!texture)
|
||||||
|
return (0);
|
||||||
|
mlx_delete_texture(texture);
|
||||||
|
}
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_texture(t_tex *tex, t_turelist *l_ture)
|
||||||
|
{
|
||||||
|
t_turelist *tmp;
|
||||||
|
|
||||||
|
if (!l_ture)
|
||||||
|
return (0);
|
||||||
|
tmp = l_ture;
|
||||||
|
if (!check_load_ture(l_ture))
|
||||||
|
return (0);
|
||||||
|
while (tmp)
|
||||||
|
{
|
||||||
|
if (!tmp->name || !tmp->value)
|
||||||
|
tmp = tmp->next;
|
||||||
|
if (!ft_strncmp(tmp->name, "NO", 2))
|
||||||
|
tex->no = mlx_load_png(tmp->value);
|
||||||
|
else if (!ft_strncmp(tmp->name, "SO", 2))
|
||||||
|
tex->so = mlx_load_png(tmp->value);
|
||||||
|
else if (!ft_strncmp(tmp->name, "WE", 2))
|
||||||
|
tex->we = mlx_load_png(tmp->value);
|
||||||
|
else if (!ft_strncmp(tmp->name, "EA", 2))
|
||||||
|
tex->ea = mlx_load_png(tmp->value);
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_angle(t_mlx *mlx)
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
|
||||||
|
c = mlx->dt->sq_map[mlx->dt->p_y][mlx->dt->p_x];
|
||||||
|
if (c == 'N')
|
||||||
|
mlx->ply->angle = 3 * M_PI / 2;
|
||||||
|
if (c == 'S')
|
||||||
|
mlx->ply->angle = M_PI / 2;
|
||||||
|
if (c == 'E')
|
||||||
|
mlx->ply->angle = 0;
|
||||||
|
if (c == 'W')
|
||||||
|
mlx->ply->angle = M_PI;
|
||||||
|
mlx->ply->plyr_x = (mlx->dt->p_x * WALL_SIZE) + WALL_SIZE / 2;
|
||||||
|
mlx->ply->plyr_y = (mlx->dt->p_y * WALL_SIZE) + WALL_SIZE / 2;
|
||||||
|
mlx->ply->fov_rd = (FOV * M_PI / 180);
|
||||||
|
}
|
||||||
|
|
||||||
|
int execution(t_data *dt)
|
||||||
|
{
|
||||||
|
t_mlx mlx;
|
||||||
|
|
||||||
|
if (S_H > 1440 || S_W > 2560 || FOV >= 180 || FOV <= 0)
|
||||||
|
return (freelist(&dt->t_list), free_map(dt), 0);
|
||||||
|
mlx.ply = (t_player *)ft_calloc(sizeof(t_player), 1);
|
||||||
|
mlx.ray = (t_ray *)ft_calloc(sizeof(t_ray), 1);
|
||||||
|
mlx.tex = (t_tex *)ft_calloc(sizeof(t_tex), 1);
|
||||||
|
mlx.dt = dt;
|
||||||
|
mlx.mlx_ptr = mlx_init(S_W, S_H, "cub3D", false);
|
||||||
|
if (!mlx.mlx_ptr)
|
||||||
|
return (ft_exit(&mlx), 0);
|
||||||
|
if (!load_texture(mlx.tex, dt->t_list))
|
||||||
|
return (ft_exit(&mlx), 0);
|
||||||
|
get_angle(&mlx);
|
||||||
|
mlx_key_hook(mlx.mlx_ptr, &key_press, &mlx);
|
||||||
|
mlx_loop_hook(mlx.mlx_ptr, &drow_map_pixel, &mlx);
|
||||||
|
mlx_loop(mlx.mlx_ptr);
|
||||||
|
ft_exit(&mlx);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
@@ -6,22 +6,22 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/12/05 17:07:58 by aortigos #+# #+# */
|
/* Created: 2025/12/05 17:07:58 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/12/05 17:10:05 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:55:15 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../../includes/cub3d.h"
|
#include "../../includes/cub3d.h"
|
||||||
|
|
||||||
void ft_delete_texture(t_texture *texture)
|
void ft_delete_texture(t_tex *tex)
|
||||||
{
|
{
|
||||||
if (texture->no)
|
if (tex->no)
|
||||||
mlx_delete_texture(texture->no);
|
mlx_delete_texture(tex->no);
|
||||||
if (texture->so)
|
if (tex->so)
|
||||||
mlx_delete_texture(texture->so);
|
mlx_delete_texture(tex->so);
|
||||||
if (texture->we)
|
if (tex->we)
|
||||||
mlx_delete_texture(texture->we);
|
mlx_delete_texture(tex->we);
|
||||||
if (texture->ea)
|
if (tex->ea)
|
||||||
mlx_delete_texture(texture->ea);
|
mlx_delete_texture(tex->ea);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ft_exit(t_mlx *mlx)
|
void ft_exit(t_mlx *mlx)
|
||||||
|
|||||||
133
src/execution/raycasting.c
Normal file
133
src/execution/raycasting.c
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* raycasting.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/12/09 18:41:15 by aortigos #+# #+# */
|
||||||
|
/* Updated: 2025/12/09 18:41:30 by aortigos ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../../includes/cub3d.h"
|
||||||
|
|
||||||
|
int inter_check(float angle, float *inter, float *step, int is_horizon)
|
||||||
|
{
|
||||||
|
if (is_horizon)
|
||||||
|
{
|
||||||
|
if (angle > 0 && angle < M_PI)
|
||||||
|
{
|
||||||
|
*inter += WALL_SIZE;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
*step *= -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(angle > M_PI / 2 && angle < 3 * M_PI / 2))
|
||||||
|
{
|
||||||
|
*inter += WALL_SIZE;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
*step *= -1;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int wall_hit(float x, float y, t_mlx *mlx)
|
||||||
|
{
|
||||||
|
int x_m;
|
||||||
|
int y_m;
|
||||||
|
|
||||||
|
if (x < 0 || y < 0)
|
||||||
|
return (0);
|
||||||
|
x_m = floor(x / WALL_SIZE);
|
||||||
|
y_m = floor(y / WALL_SIZE);
|
||||||
|
if ((y_m >= mlx->dt->h_map || x_m >= mlx->dt->w_map))
|
||||||
|
return (0);
|
||||||
|
if (mlx->dt->map2d[y_m] && x_m <= (int)ft_strlen(mlx->dt->map2d[y_m]))
|
||||||
|
if (mlx->dt->map2d[y_m][x_m] == '1')
|
||||||
|
return (0);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
float get_h_inter(t_mlx *mlx, float angl)
|
||||||
|
{
|
||||||
|
float h_x;
|
||||||
|
float h_y;
|
||||||
|
float x_step;
|
||||||
|
float y_step;
|
||||||
|
int pixel;
|
||||||
|
|
||||||
|
y_step = WALL_SIZE;
|
||||||
|
x_step = WALL_SIZE / tan(angl);
|
||||||
|
h_y = floor(mlx->ply->plyr_y / WALL_SIZE) * WALL_SIZE;
|
||||||
|
pixel = inter_check(angl, &h_y, &y_step, 1);
|
||||||
|
h_x = mlx->ply->plyr_x + (h_y - mlx->ply->plyr_y) / tan(angl);
|
||||||
|
if ((unit_circle(angl, 'y') && x_step > 0) || (!unit_circle(angl, 'y')
|
||||||
|
&& x_step < 0))
|
||||||
|
x_step *= -1;
|
||||||
|
while (wall_hit(h_x, h_y - pixel, mlx))
|
||||||
|
{
|
||||||
|
h_x += x_step;
|
||||||
|
h_y += y_step;
|
||||||
|
}
|
||||||
|
mlx->ray->horiz_x = h_x;
|
||||||
|
mlx->ray->horiz_y = h_y;
|
||||||
|
return (sqrt(pow(h_x - mlx->ply->plyr_x, 2) + pow(h_y - mlx->ply->plyr_y,
|
||||||
|
2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
float get_v_inter(t_mlx *mlx, float angl)
|
||||||
|
{
|
||||||
|
float v_x;
|
||||||
|
float v_y;
|
||||||
|
float x_step;
|
||||||
|
float y_step;
|
||||||
|
int pixel;
|
||||||
|
|
||||||
|
x_step = WALL_SIZE;
|
||||||
|
y_step = WALL_SIZE * tan(angl);
|
||||||
|
v_x = floor(mlx->ply->plyr_x / WALL_SIZE) * WALL_SIZE;
|
||||||
|
pixel = inter_check(angl, &v_x, &x_step, 0);
|
||||||
|
v_y = mlx->ply->plyr_y + (v_x - mlx->ply->plyr_x) * tan(angl);
|
||||||
|
if ((unit_circle(angl, 'x') && y_step < 0) || (!unit_circle(angl, 'x')
|
||||||
|
&& y_step > 0))
|
||||||
|
y_step *= -1;
|
||||||
|
while (wall_hit(v_x - pixel, v_y, mlx))
|
||||||
|
{
|
||||||
|
v_x += x_step;
|
||||||
|
v_y += y_step;
|
||||||
|
}
|
||||||
|
mlx->ray->vert_x = v_x;
|
||||||
|
mlx->ray->vert_y = v_y;
|
||||||
|
return (sqrt(pow(v_x - mlx->ply->plyr_x, 2) + pow(v_y - mlx->ply->plyr_y,
|
||||||
|
2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void cast_rays(t_mlx *mlx)
|
||||||
|
{
|
||||||
|
double h_inter;
|
||||||
|
double v_inter;
|
||||||
|
int ray;
|
||||||
|
|
||||||
|
ray = 0;
|
||||||
|
mlx->ray->ray_ngl = mlx->ply->angle - (mlx->ply->fov_rd / 2);
|
||||||
|
while (ray < S_W)
|
||||||
|
{
|
||||||
|
mlx->ray->flag = 0;
|
||||||
|
h_inter = get_h_inter(mlx, nor_angle(mlx->ray->ray_ngl));
|
||||||
|
v_inter = get_v_inter(mlx, nor_angle(mlx->ray->ray_ngl));
|
||||||
|
if (v_inter <= h_inter)
|
||||||
|
mlx->ray->distance = v_inter;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mlx->ray->distance = h_inter;
|
||||||
|
mlx->ray->flag = 1;
|
||||||
|
}
|
||||||
|
render_wall(mlx, ray);
|
||||||
|
ray++;
|
||||||
|
mlx->ray->ray_ngl += (mlx->ply->fov_rd / S_W);
|
||||||
|
}
|
||||||
|
}
|
||||||
106
src/execution/render.c
Normal file
106
src/execution/render.c
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* render.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/12/09 18:42:30 by aortigos #+# #+# */
|
||||||
|
/* Updated: 2025/12/09 19:55:21 by aortigos ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../../includes/cub3d.h"
|
||||||
|
|
||||||
|
void draw_floor_ceiling(t_mlx *mlx, int ray, int t_pix, int b_pix)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int c;
|
||||||
|
|
||||||
|
i = b_pix;
|
||||||
|
c = get_rgba(ft_atoi(mlx->dt->ff[0]), ft_atoi(mlx->dt->ff[1]),
|
||||||
|
ft_atoi(mlx->dt->ff[2]), 255);
|
||||||
|
while (i < S_H)
|
||||||
|
my_mlx_pixel_put(mlx, ray, i++, c);
|
||||||
|
c = get_rgba(ft_atoi(mlx->dt->cc[0]), ft_atoi(mlx->dt->cc[1]),
|
||||||
|
ft_atoi(mlx->dt->cc[2]), 255);
|
||||||
|
i = 0;
|
||||||
|
while (i < t_pix)
|
||||||
|
my_mlx_pixel_put(mlx, ray, i++, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
mlx_texture_t *get_texture(t_mlx *mlx, int flag)
|
||||||
|
{
|
||||||
|
mlx->ray->ray_ngl = nor_angle(mlx->ray->ray_ngl);
|
||||||
|
if (flag == 0)
|
||||||
|
{
|
||||||
|
if (mlx->ray->ray_ngl > M_PI / 2 && mlx->ray->ray_ngl < 3 * (M_PI / 2))
|
||||||
|
return (mlx->tex->ea);
|
||||||
|
else
|
||||||
|
return (mlx->tex->we);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mlx->ray->ray_ngl > 0 && mlx->ray->ray_ngl < M_PI)
|
||||||
|
return (mlx->tex->so);
|
||||||
|
else
|
||||||
|
return (mlx->tex->no);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double get_x_o(mlx_texture_t *texture, t_mlx *mlx)
|
||||||
|
{
|
||||||
|
double x_o;
|
||||||
|
|
||||||
|
if (mlx->ray->flag == 1)
|
||||||
|
x_o = (int)fmodf((mlx->ray->horiz_x * (texture->width / WALL_SIZE)),
|
||||||
|
texture->width);
|
||||||
|
else
|
||||||
|
x_o = (int)fmodf((mlx->ray->vert_y * (texture->width / WALL_SIZE)),
|
||||||
|
texture->width);
|
||||||
|
return (x_o);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_wall(t_mlx *mlx, int t_pix, int b_pix, double wall_h)
|
||||||
|
{
|
||||||
|
double x_o;
|
||||||
|
double y_o;
|
||||||
|
mlx_texture_t *texture;
|
||||||
|
uint32_t *arr;
|
||||||
|
double factor;
|
||||||
|
|
||||||
|
texture = get_texture(mlx, mlx->ray->flag);
|
||||||
|
arr = (uint32_t *)texture->pixels;
|
||||||
|
factor = (double)texture->height / wall_h;
|
||||||
|
x_o = get_x_o(texture, mlx);
|
||||||
|
y_o = (t_pix - (S_H / 2) + (wall_h / 2)) * factor;
|
||||||
|
if (y_o < 0)
|
||||||
|
y_o = 0;
|
||||||
|
while (t_pix < b_pix)
|
||||||
|
{
|
||||||
|
my_mlx_pixel_put(mlx, mlx->ray->index, t_pix, reverse_bytes(arr[(int)y_o
|
||||||
|
* texture->width + (int)x_o]));
|
||||||
|
y_o += factor;
|
||||||
|
t_pix++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void render_wall(t_mlx *mlx, int ray)
|
||||||
|
{
|
||||||
|
double wall_h;
|
||||||
|
double b_pix;
|
||||||
|
double t_pix;
|
||||||
|
|
||||||
|
mlx->ray->distance *= cos(nor_angle(mlx->ray->ray_ngl - mlx->ply->angle));
|
||||||
|
wall_h = (WALL_SIZE / mlx->ray->distance) * ((S_W / 2)
|
||||||
|
/ tan(mlx->ply->fov_rd / 2));
|
||||||
|
b_pix = (S_H / 2) + (wall_h / 2);
|
||||||
|
t_pix = (S_H / 2) - (wall_h / 2);
|
||||||
|
if (b_pix > S_H)
|
||||||
|
b_pix = S_H;
|
||||||
|
if (t_pix < 0)
|
||||||
|
t_pix = 0;
|
||||||
|
mlx->ray->index = ray;
|
||||||
|
draw_wall(mlx, t_pix, b_pix, wall_h);
|
||||||
|
draw_floor_ceiling(mlx, ray, t_pix, b_pix);
|
||||||
|
}
|
||||||
67
src/execution/render2.c
Normal file
67
src/execution/render2.c
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* render2.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/12/09 18:44:12 by aortigos #+# #+# */
|
||||||
|
/* Updated: 2025/12/09 18:44:40 by aortigos ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../../includes/cub3d.h"
|
||||||
|
|
||||||
|
int get_rgba(int r, int g, int b, int a)
|
||||||
|
{
|
||||||
|
return (r << 24 | g << 16 | b << 8 | a << 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int reverse_bytes(int c)
|
||||||
|
{
|
||||||
|
unsigned int b;
|
||||||
|
|
||||||
|
b = 0;
|
||||||
|
b |= (c & 0xFF) << 24;
|
||||||
|
b |= (c & 0xFF00) << 8;
|
||||||
|
b |= (c & 0xFF0000) >> 8;
|
||||||
|
b |= (c & 0xFF000000) >> 24;
|
||||||
|
return (b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void my_mlx_pixel_put(t_mlx *mlx, int x, int y, int color)
|
||||||
|
{
|
||||||
|
if (x < 0)
|
||||||
|
return ;
|
||||||
|
else if (x >= S_W)
|
||||||
|
return ;
|
||||||
|
if (y < 0)
|
||||||
|
return ;
|
||||||
|
else if (y >= S_H)
|
||||||
|
return ;
|
||||||
|
mlx_put_pixel(mlx->img, x, y, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
float nor_angle(float angle)
|
||||||
|
{
|
||||||
|
if (angle < 0)
|
||||||
|
angle += (2 * M_PI);
|
||||||
|
if (angle > (2 * M_PI))
|
||||||
|
angle -= (2 * M_PI);
|
||||||
|
return (angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
int unit_circle(float angle, char c)
|
||||||
|
{
|
||||||
|
if (c == 'x')
|
||||||
|
{
|
||||||
|
if (angle > 0 && angle < M_PI)
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
else if (c == 'y')
|
||||||
|
{
|
||||||
|
if (angle > (M_PI / 2) && angle < (3 * M_PI) / 2)
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/11/14 09:35:53 by aortigos #+# #+# */
|
/* Created: 2025/11/14 09:35:53 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/11/16 20:29:38 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:45:29 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/11/28 20:03:22 by aortigos #+# #+# */
|
/* Created: 2025/11/28 20:03:22 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/11/28 20:09:04 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:46:17 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* textures.c :+: :+: :+: */
|
/* lst_textures.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/12/01 08:48:55 by aortigos #+# #+# */
|
/* Created: 2025/12/01 08:48:55 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/12/01 10:02:55 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:51:07 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/11/25 19:47:38 by aortigos #+# #+# */
|
/* Created: 2025/11/25 19:47:38 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/11/28 20:01:02 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:47:13 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/12/04 09:28:05 by aortigos #+# #+# */
|
/* Created: 2025/12/04 09:28:05 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/12/04 09:59:45 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:52:54 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -26,12 +26,13 @@ int is_validmap(char *line, int *flag)
|
|||||||
i = -1;
|
i = -1;
|
||||||
while (line[++i])
|
while (line[++i])
|
||||||
{
|
{
|
||||||
if ((line[i] != '1' && line[i] != 32 && line[i] != '0'
|
if ((line[i] != '1' && line[i] != '0'
|
||||||
&& line[i] != '\n') && !(line[i] != 'W' || line[i] != 'E'
|
&& line[i] != ' ' && line[i] != '\n'
|
||||||
|| line[i] != 'N' || line[i] != 'S'))
|
&& line[i] != 'W' && line[i] != 'E'
|
||||||
|
&& line[i] != 'N' && line[i] != 'S'))
|
||||||
return (0);
|
return (0);
|
||||||
else if (line[i] != 'W' || line[i] != 'E' || line[i] != 'N'
|
else if (line[i] == 'W' || line[i] == 'E' || line[i] == 'N'
|
||||||
|| line[i] != 'S')
|
|| line[i] == 'S')
|
||||||
(*flag)++;
|
(*flag)++;
|
||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
@@ -45,8 +46,8 @@ char *getmap(t_data *map)
|
|||||||
while (map->line)
|
while (map->line)
|
||||||
{
|
{
|
||||||
if (map->line[0] == '\n')
|
if (map->line[0] == '\n')
|
||||||
return (ft_putstr_fd(ERR_MAP_EMPTY, 2), freetl(map->map, map->line,
|
return (ft_putstr_fd(ERR_MAP_EMPTY, 2),
|
||||||
-1), NULL);
|
freetl(map->map, map->line, -1), NULL);
|
||||||
tmp = ft_strjoin(map->map, map->line);
|
tmp = ft_strjoin(map->map, map->line);
|
||||||
ft_memfree(map->map);
|
ft_memfree(map->map);
|
||||||
ft_memfree(map->line);
|
ft_memfree(map->line);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/12/04 10:07:52 by aortigos #+# #+# */
|
/* Created: 2025/12/04 10:07:52 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/12/04 10:32:30 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:51:28 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/12/05 15:42:28 by aortigos #+# #+# */
|
/* Created: 2025/12/05 15:42:28 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/12/05 16:06:21 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:55:01 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ int check_color_values(char **rgb)
|
|||||||
|
|
||||||
void ft_process_rgb_color(t_turelist *tmp, t_data *m)
|
void ft_process_rgb_color(t_turelist *tmp, t_data *m)
|
||||||
{
|
{
|
||||||
if (!f_strncmp(tmp->name, "F", 2))
|
if (!ft_strncmp(tmp->name, "F", 2))
|
||||||
m->ff = ft_split(tmp->value, ',');
|
m->ff = ft_split(tmp->value, ',');
|
||||||
else if (!ft_strncmp(tmp->name, "C", 2))
|
else if (!ft_strncmp(tmp->name, "C", 2))
|
||||||
m->cc = ft_split(tmp->value, ',');
|
m->cc = ft_split(tmp->value, ',');
|
||||||
@@ -35,15 +35,18 @@ void ft_process_rgb_color(t_turelist *tmp, t_data *m)
|
|||||||
int color_ture(t_data *m, t_turelist *l_ture)
|
int color_ture(t_data *m, t_turelist *l_ture)
|
||||||
{
|
{
|
||||||
t_turelist *tmp;
|
t_turelist *tmp;
|
||||||
|
char **colors;
|
||||||
|
|
||||||
m->cc = NULL;
|
m->cc = NULL;
|
||||||
m->ff = NULL;
|
m->ff = NULL;
|
||||||
tmp = l_ture;
|
tmp = l_ture;
|
||||||
while (tmp)
|
while (tmp)
|
||||||
{
|
{
|
||||||
if (!ft_strncmp(tmp->name, "F", 1) || !ft_strncmp(tmp->name, "C", 1))
|
if (tmp->name && (!ft_strncmp(tmp->name, "F", 1)
|
||||||
|
|| !ft_strncmp(tmp->name, "C", 1)))
|
||||||
{
|
{
|
||||||
if (!check_color_values(ft_split(tmp->value, ',')))
|
colors = ft_split(tmp->value, ',');
|
||||||
|
if (!check_color_values(colors))
|
||||||
return (ft_putstr_fd(ERR_MAP_RGB, 2), 0);
|
return (ft_putstr_fd(ERR_MAP_RGB, 2), 0);
|
||||||
ft_process_rgb_color(tmp, m);
|
ft_process_rgb_color(tmp, m);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/12/05 16:09:33 by aortigos #+# #+# */
|
/* Created: 2025/12/05 16:09:33 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/12/05 16:29:28 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:50:46 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../../cub3d.h"
|
#include "../../includes/cub3d.h"
|
||||||
|
|
||||||
int is_valid_texture(char *line)
|
int is_valid_texture(char *line)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/12/05 16:30:33 by aortigos #+# #+# */
|
/* Created: 2025/12/05 16:30:33 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/12/05 16:53:44 by aortigos ### ########.fr */
|
/* Updated: 2025/12/09 19:49:06 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ int h_map(char **map)
|
|||||||
j = 0;
|
j = 0;
|
||||||
while (map[i][j])
|
while (map[i][j])
|
||||||
{
|
{
|
||||||
if (map[i][j] != '1' && map [i][j] != ' ')
|
if (map[i][j] != '1' || map [i][j] != ' ')
|
||||||
if (map[i][j - 1] == ' ' || map[i][j + 1] == ' ')
|
if (map[i][j - 1] == ' ' || map[i][j + 1] == ' ')
|
||||||
return (ft_putstr_fd(ERR_MAP_INV, 2), 0);
|
return (ft_putstr_fd(ERR_MAP_INV, 2), 0);
|
||||||
j++;
|
j++;
|
||||||
@@ -76,7 +76,6 @@ char *fixline(char *line, int maxlen)
|
|||||||
return (new);
|
return (new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int getsize_line(char **map)
|
int getsize_line(char **map)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
Reference in New Issue
Block a user