mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
feat(barricades): added multiple textures for the barricades
This commit is contained in:
parent
40e71b4616
commit
5591ebd937
10 changed files with 992 additions and 7 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:59:37 by kcolin #+# #+# */
|
||||
/* Updated: 2025/09/09 09:55:15 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/09/10 14:56:37 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ typedef struct s_cub3d_data
|
|||
t_img_data *so_texture;
|
||||
t_img_data *we_texture;
|
||||
t_img_data *ea_texture;
|
||||
t_img_data *barricades_texture;
|
||||
t_img_data *barricades_texture[7];
|
||||
t_img_data *img_data;
|
||||
t_img_data *point_figures[10];
|
||||
t_img_data *perk_logos[3];
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/09/03 17:02:08 by tchampio #+# #+# */
|
||||
/* Updated: 2025/09/09 14:08:39 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/09/10 14:56:33 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -97,8 +97,20 @@ void load_textures(t_cub3d_data *data)
|
|||
data->so_texture = load_single_texture(data, data->map->so_texture);
|
||||
data->we_texture = load_single_texture(data, data->map->we_texture);
|
||||
data->ea_texture = load_single_texture(data, data->map->ea_texture);
|
||||
data->barricades_texture = load_single_texture(data,
|
||||
"ressources/barricades.xpm");
|
||||
data->barricades_texture[0] = load_single_texture(data,
|
||||
"ressources/barricades_2.xpm");
|
||||
data->barricades_texture[1] = load_single_texture(data,
|
||||
"ressources/barricades_3.xpm");
|
||||
data->barricades_texture[2] = load_single_texture(data,
|
||||
"ressources/barricades_4.xpm");
|
||||
data->barricades_texture[3] = load_single_texture(data,
|
||||
"ressources/barricades_5.xpm");
|
||||
data->barricades_texture[4] = load_single_texture(data,
|
||||
"ressources/barricades_6.xpm");
|
||||
data->barricades_texture[5] = load_single_texture(data,
|
||||
"ressources/barricades_7.xpm");
|
||||
data->barricades_texture[6] = load_single_texture(data,
|
||||
"ressources/barricades_8.xpm");
|
||||
load_points_textures(data);
|
||||
load_perk_logos(data);
|
||||
load_round_indicators(data);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/31 13:17:39 by kcolin #+# #+# */
|
||||
/* Updated: 2025/09/09 09:59:45 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/09/10 14:57:32 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -35,6 +35,25 @@ t_cardinal_dir get_cardinal(t_ray *ray)
|
|||
}
|
||||
}
|
||||
|
||||
t_img_data *get_right_barricade(t_cub3d_data *data, char c)
|
||||
{
|
||||
if (c == '2')
|
||||
return (data->barricades_texture[0]);
|
||||
if (c == '3')
|
||||
return (data->barricades_texture[1]);
|
||||
if (c == '4')
|
||||
return (data->barricades_texture[2]);
|
||||
if (c == '5')
|
||||
return (data->barricades_texture[3]);
|
||||
if (c == '6')
|
||||
return (data->barricades_texture[4]);
|
||||
if (c == '7')
|
||||
return (data->barricades_texture[5]);
|
||||
if (c == '8')
|
||||
return (data->barricades_texture[6]);
|
||||
return (data->so_texture);
|
||||
}
|
||||
|
||||
static int get_color(t_cub3d_data *data, t_ray *ray, int tex_y)
|
||||
{
|
||||
t_cardinal_dir dir;
|
||||
|
|
@ -47,7 +66,7 @@ static int get_color(t_cub3d_data *data, t_ray *ray, int tex_y)
|
|||
tex_x = TEXTURE_SIZE - tex_x - 1;
|
||||
dir = get_cardinal(ray);
|
||||
if (ft_strchr("2345678", data->map->map[ray->map_y][ray->map_x]))
|
||||
return (my_mlx_pixel_get(data->barricades_texture, tex_x, tex_y));
|
||||
return (my_mlx_pixel_get(get_right_barricade(data, data->map->map[ray->map_y][ray->map_x]), tex_x, tex_y));
|
||||
if (dir == NORTH)
|
||||
texture = data->no_texture;
|
||||
else if (dir == SOUTH)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue