From bcdeec3271271c62a2284d27b1b59736d3011edc Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 22 Nov 2024 22:02:57 +0100 Subject: [PATCH] feat: adding the visualisation of the raycating but crashed --- Makefile | 2 +- raycast/rc_utils.c | 48 +++++++++++++++++++++------------------------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index cc5d027..03d6fb9 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ CFLAGS += -g3 -MMD # CFLAGS += -fsanitize=address # CFLAGS += -fsanitize=thread -INCLUDES = -I /opt/X11/include -I ./includes -I ./includes/include -I ./minilibx-linux +INCLUDES = -I /usr/include -I /opt/X11/include -I ./includes -I ./includes/include -I ./minilibx-linux # Paths LIBFT_DIR = ./libft diff --git a/raycast/rc_utils.c b/raycast/rc_utils.c index c72c69e..5bd88cb 100644 --- a/raycast/rc_utils.c +++ b/raycast/rc_utils.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/12 12:24:35 by rparodi #+# #+# */ -/* Updated: 2024/11/22 15:35:10 by rparodi ### ########.fr */ +/* Updated: 2024/11/22 20:01:59 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,7 +40,7 @@ double cub_convert_deg_to_rad(double degrees) */ double rc_launch(t_info *info, double angle) { - double distance; + double distance; t_dpoint direction; t_dpoint rayon; @@ -85,15 +85,11 @@ double cub_convert_deg_to_rad(double degrees) } } - /* ----------------------------------- */ - /* Some utils for the mlx window view */ - /* ----------------------------------- */ - t_win_list *c3_init_mlx_window(t_info *info) { - void *window; - int i; - int j; + void *window; + int i; + int j; int x; int y; @@ -101,21 +97,21 @@ double cub_convert_deg_to_rad(double degrees) y = 0; mlx_get_screen_size(info->mlx_ptr, &x, &y); - i = 0; - window = mlx_new_window(info->mlx_ptr, x, y, "Raycasting"); - while (i < x) - { - j = 0; - while (j < y) - { - if (info->map.fraw[i / info->map.size.x][j / info->map.size.y] == '1') - mlx_pixel_put(info->mlx_ptr, window, i, j, 0xFFFFFF); - else - mlx_pixel_put(info->mlx_ptr, window, i, j, 0x000000); - j++; - } - i++; - } - mlx_loop(info->mlx_ptr); - return (window); + i = 0; + window = mlx_new_window(info->mlx_ptr, x, y, "Raycasting"); + while (i < x) + { + j = 0; + while (j < y) + { + if (info->map.fraw[i / info->map.size.x][j / info->map.size.y] == '1') + mlx_pixel_put(info->mlx_ptr, window, i, j, 0xFFFFFF); + else + mlx_pixel_put(info->mlx_ptr, window, i, j, 0x000000); + j++; + } + i++; + } + mlx_loop(info->mlx_ptr); + return (window); }