diff --git a/src/sprites/sprite_caster.c b/src/sprites/sprite_caster.c index 23e3657..ff5c713 100644 --- a/src/sprites/sprite_caster.c +++ b/src/sprites/sprite_caster.c @@ -6,7 +6,7 @@ /* By: tchampio +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/08/05 15:51:01 by tchampio #+# #+# */ -/* Updated: 2025/08/18 13:39:26 by tchampio ### ########.fr */ +/* Updated: 2025/08/19 19:42:43 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,6 @@ #include "../renderer/render.h" #include "sort_sprites.h" #include -#include #include "../../libft/includes/libft.h" static void calculate_pos_and_transform(t_cub3d_data *data, t_sprite *sprite, @@ -73,6 +72,8 @@ static void render_sprite_col(t_cub3d_data *data, int i, int tex_x, int stripe) d = (j) * 256 - HEIGHT * 128 + data->sprite_list[i]->sprite_height * 128; tex_y = ((d * SIZE) / data->sprite_list[i]->sprite_height) / 256; + if (tex_y < 0) + tex_y = 0; color = my_mlx_pixel_get( data->sprite_list[data->sprite_order[i]]->image, tex_x, tex_y); @@ -94,6 +95,8 @@ static void render_sprites(t_cub3d_data *data, int i) - (-data->sprite_list[i]->sprite_width / 2 + data->sprite_list[i]->sprite_screen_x)) * SIZE / data->sprite_list[i]->sprite_width) / 256; + if (tex_x < 0) + tex_x = 0; if (data->sprite_list[i]->transform_y > 0 && stripe > 0 && stripe < WIDTH && data->sprite_list[i]->transform_y < data->zbuffer[stripe])