From 27af85052596d5f7fc251ee6f5cef6ab07b73642 Mon Sep 17 00:00:00 2001 From: Theo Champion Date: Mon, 15 Sep 2025 13:11:59 +0200 Subject: [PATCH] norme: Fixed norme errors --- src/hud/hud.c | 5 +++-- src/raycast/ray.c | 16 +++------------- src/raycast/zombie_checker.c | 34 ++++++++++++++++++++++++++++++++++ src/raycast/zombie_checker.h | 21 +++++++++++++++++++++ src/utils/destroy_utils.c | 3 ++- src/utils/inits.h | 4 ++-- 6 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 src/raycast/zombie_checker.c create mode 100644 src/raycast/zombie_checker.h diff --git a/src/hud/hud.c b/src/hud/hud.c index 6c9fbe4..e27c828 100644 --- a/src/hud/hud.c +++ b/src/hud/hud.c @@ -6,7 +6,7 @@ /* By: tchampio +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/09/08 17:27:12 by tchampio #+# #+# */ -/* Updated: 2025/09/10 15:59:15 by tchampio ### ########.fr */ +/* Updated: 2025/09/15 13:06:07 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ @@ -84,5 +84,6 @@ void create_hud(t_cub3d_data *data) draw_points(data); draw_perks(data); draw_round(data); - matrix_image_put(data, data->player.weapon.texture, WIDTH / 2, HEIGHT - 175); + matrix_image_put(data, data->player.weapon.texture, + WIDTH / 2, HEIGHT - 175); } diff --git a/src/raycast/ray.c b/src/raycast/ray.c index 688d1b5..44bf283 100644 --- a/src/raycast/ray.c +++ b/src/raycast/ray.c @@ -6,11 +6,12 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/31 11:55:41 by kcolin #+# #+# */ -/* Updated: 2025/09/14 17:40:53 by tchampio ### ########.fr */ +/* Updated: 2025/09/15 13:11:37 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ #include "ray.h" +#include "zombie_checker.h" #include "barricades.h" #include "raycaster.h" #include "../player/player.h" @@ -58,21 +59,10 @@ void ray_calculate_step(t_ray *ray, t_player *player) void calculate_wall_dist(t_ray *ray, int x, t_cub3d_data *data) { - int i; while (true) { if (x == WIDTH / 2) - { - i = 0; - while (i < data->sprite_counter) - { - if (data->sprite_list[i]->sprite_type == ZOMBIE && ray->map_x == (int)data->sprite_list[i]->x && ray->map_y == (int)data->sprite_list[i]->y) - { - ft_printf("Zombie found\n"); - } - i++; - } - } + check_for_zombies(ray, data); if (ray->side_dist_x < ray->side_dist_y) { ray->side_dist_x += ray->delta_dist_x; diff --git a/src/raycast/zombie_checker.c b/src/raycast/zombie_checker.c new file mode 100644 index 0000000..06408ea --- /dev/null +++ b/src/raycast/zombie_checker.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* zombie_checker.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tchampio +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/09/15 13:08:48 by tchampio #+# #+# */ +/* Updated: 2025/09/15 13:09:38 by tchampio ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ray.h" +#include "../cub3d_data.h" +#include "../../libft/includes/libft.h" + +void check_for_zombies(t_ray *ray, t_cub3d_data *data) +{ + int i; + + i = 0; + while (i < data->sprite_counter) + { + if (data->sprite_list[i]->sprite_type == ZOMBIE + && ray->map_x == (int)data->sprite_list[i]->x + && ray->map_y == (int)data->sprite_list[i]->y) + { + ft_printf("Zombie found %p\n", data->sprite_list[i]); + break ; + } + i++; + } +} + diff --git a/src/raycast/zombie_checker.h b/src/raycast/zombie_checker.h new file mode 100644 index 0000000..a71faad --- /dev/null +++ b/src/raycast/zombie_checker.h @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* zombie_checker.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tchampio +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/09/15 13:09:54 by tchampio #+# #+# */ +/* Updated: 2025/09/15 13:10:44 by tchampio ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef ZOMBIE_CHECKER_H +# define ZOMBIE_CHECKER_H + +# include "ray.h" +# include "../cub3d_data.h" + +void check_for_zombies(t_ray *ray, t_cub3d_data *data); + +#endif // ZOMBIE_CHECKER_H diff --git a/src/utils/destroy_utils.c b/src/utils/destroy_utils.c index 6b2369a..b4614bc 100644 --- a/src/utils/destroy_utils.c +++ b/src/utils/destroy_utils.c @@ -6,7 +6,7 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/08/18 13:05:31 by kcolin #+# #+# */ -/* Updated: 2025/09/10 16:00:47 by tchampio ### ########.fr */ +/* Updated: 2025/09/15 13:05:37 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,6 +26,7 @@ void destroy_texture(t_cub3d_data *data, t_img_data *data_img) void destroy_textures(t_cub3d_data *data) { int i; + if (data->no_texture) mlx_destroy_image(data->mlx, data->no_texture->img); free(data->no_texture); diff --git a/src/utils/inits.h b/src/utils/inits.h index 203d2e9..cc4a149 100644 --- a/src/utils/inits.h +++ b/src/utils/inits.h @@ -6,7 +6,7 @@ /* By: tchampio