cub3d/src/texture/texutre_load.c
2025-05-06 19:03:21 +02:00

54 lines
1.9 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* texutre_load.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/06 15:45:58 by qmennen #+# #+# */
/* Updated: 2025/05/06 19:01:15 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
#include "texture.h"
void texture_delete(t_game *game)
{
int i;
i = 0;
while (i < 4)
{
if (game->map->textures[i])
mlx_delete_texture(game->map->textures[i]);
i++;
}
if (game->map->texture_floor)
{
mlx_delete_texture(game->map->texture_floor);
game->map->texture_floor = NULL;
}
if (game->map->texture_ceiling)
{
mlx_delete_texture(game->map->texture_ceiling);
game->map->texture_ceiling = NULL;
}
}
int texture_load(t_game *game)
{
game->map->textures[SIDE_NORTH] = mlx_load_png(game->map->NO_texture);
game->map->textures[SIDE_EAST] = mlx_load_png(game->map->EA_texture);
game->map->textures[SIDE_SOUTH] = mlx_load_png(game->map->SO_texture);
game->map->textures[SIDE_WEST] = mlx_load_png(game->map->WE_texture);
game->map->texture_floor = mlx_load_png("./assets/floor.png");
game->map->texture_ceiling = mlx_load_png("./assets/ceiling64x64.png");
if (!game->map->textures[SIDE_NORTH] || !game->map->textures[SIDE_EAST]
|| !game->map->textures[SIDE_SOUTH] || !game->map->textures[SIDE_WEST])
{
texture_delete(game);
return (FAILURE);
}
return (SUCCESS);
}