-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete.c
67 lines (63 loc) · 2.11 KB
/
delete.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* delete.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: antandre <antandre@student.42barcel> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/04 13:40:23 by antandre #+# #+# */
/* Updated: 2024/10/22 19:46:17 by antandre ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void delete_textures(t_game *game)
{
if (game->txt)
{
if (game->txt->floor)
mlx_delete_texture(game->txt->floor);
if (game->txt->wall)
mlx_delete_texture(game->txt->wall);
if (game->txt->exit1)
mlx_delete_texture(game->txt->exit1);
if (game->txt->exit2)
mlx_delete_texture(game->txt->exit2);
if (game->txt->pnj)
mlx_delete_texture(game->txt->pnj);
if (game->txt->collect)
mlx_delete_texture(game->txt->collect);
free(game->txt);
game->txt = NULL;
}
}
void delete_images(t_game *game)
{
if (game->img)
{
if (game->img->floor)
mlx_delete_image(game->mlx, game->img->floor);
if (game->img->wall)
mlx_delete_image(game->mlx, game->img->wall);
if (game->img->exit1)
mlx_delete_image(game->mlx, game->img->exit1);
if (game->img->exit2)
mlx_delete_image(game->mlx, game->img->exit2);
if (game->img->pnj)
mlx_delete_image(game->mlx, game->img->pnj);
if (game->img->collect)
mlx_delete_image(game->mlx, game->img->collect);
free(game->img);
game->img = NULL;
}
}
void clean_up(t_game *game)
{
delete_images(game);
delete_textures(game);
if (game->mlx)
mlx_terminate(game->mlx);
if (game->map.array || game->map.info)
free_map(game);
if (game->fd > 0)
close(game->fd);
}