From f21b8dc44836eda173f33e57a5cad7995438e082 Mon Sep 17 00:00:00 2001 From: Theo Champion Date: Wed, 30 Jul 2025 16:40:33 +0200 Subject: [PATCH] fix: fixed norme --- src/consts.h | 3 ++- src/raycast/ray.h | 18 +++++++++--------- src/raycast/render.c | 17 ++++++++--------- src/renderer/render.c | 5 +++-- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/consts.h b/src/consts.h index d9b1792..2ebcf5b 100644 --- a/src/consts.h +++ b/src/consts.h @@ -6,7 +6,7 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/17 14:54:36 by kcolin #+# #+# */ -/* Updated: 2025/07/29 14:28:45 by tchampio ### ########.fr */ +/* Updated: 2025/07/30 16:38:32 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,6 +32,7 @@ extern const float g_southeast; # define MOVEMENT_SPEED 0.1 # define ROTATION_SPEED 0.1 # define PLANE_VALUE 0.66 +# define TEXTURE_SIZE 64 # ifdef BONUS # define COMPILED_TEXT "Compiled with bonuses" # else diff --git a/src/raycast/ray.h b/src/raycast/ray.h index 9457544..ca8e9f6 100644 --- a/src/raycast/ray.h +++ b/src/raycast/ray.h @@ -6,7 +6,7 @@ /* By: tchampio +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/30 12:50:10 by tchampio #+# #+# */ -/* Updated: 2025/07/30 16:22:42 by tchampio ### ########.fr */ +/* Updated: 2025/07/30 16:38:59 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,7 +30,6 @@ int get_cardinal(t_ray *ray) else return (0); } - } /* @@ -47,20 +46,20 @@ void render_walls(t_cub3d_data *data, t_ray *ray, int x) unsigned int color; double step; double pos; - static int texture_size = 64; // to be changed in favor of a const dir = get_cardinal(ray); - tex_x = (int)(ray->wall_x * texture_size); - if ((ray->side == 0 && ray->dir_x < 0) || (ray->side == 1 && ray->dir_y > 0)) - tex_x = texture_size - tex_x - 1; - step = 1.0 * texture_size / ray->wall_height; + tex_x = (int)(ray->wall_x * TEXTURE_SIZE); + if ((ray->side == 0 && ray->dir_x < 0) + || (ray->side == 1 && ray->dir_y > 0)) + tex_x = TEXTURE_SIZE - tex_x - 1; + step = 1.0 * TEXTURE_SIZE / ray->wall_height; pos = (ray->draw_start - HEIGHT / 2 + ray->wall_height / 2) * step; while (ray->draw_start < ray->draw_end) { pos += step; color = 0x0000ff; - (void)dir; // cc complains otherwise - (void)pos; // cc complains otherwise + (void)dir; + (void)pos; data->screen_matrix[ray->draw_start][x] = color; ray->draw_start++; } diff --git a/src/renderer/render.c b/src/renderer/render.c index d39ae85..2b3b399 100644 --- a/src/renderer/render.c +++ b/src/renderer/render.c @@ -6,7 +6,7 @@ /* By: tchampio +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/30 14:53:39 by tchampio #+# #+# */ -/* Updated: 2025/07/30 16:21:18 by tchampio ### ########.fr */ +/* Updated: 2025/07/30 16:39:51 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,7 +46,8 @@ void matrix_to_image(t_cub3d_data *data) while (x < WIDTH) { if (data->screen_matrix[y][x] > 0) - my_mlx_pixel_put(data->img_data, x, y, data->screen_matrix[y][x]); + my_mlx_pixel_put(data->img_data, + x, y, data->screen_matrix[y][x]); x++; } y++;