-
Notifications
You must be signed in to change notification settings - Fork 0
/
so_long_utils2.c
75 lines (66 loc) · 1.7 KB
/
so_long_utils2.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
68
69
70
71
72
73
74
75
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* so_long_utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: azaghlou <azaghlou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/19 15:03:09 by azaghlou #+# #+# */
/* Updated: 2023/03/07 20:09:52 by azaghlou ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void free_fct(char **ar, t_list *p)
{
int j;
j = 0;
while (j < count_lines(p))
{
free(ar[j]);
j++;
}
}
void ft_putstr(char *s)
{
int i;
i = 0;
while (s[i])
{
write(1, &s[i], 1);
i++;
}
}
void ft_putnbr(int i)
{
char s;
if (i >= 10)
{
ft_putnbr(i / 10);
ft_putnbr(i % 10);
}
else
{
s = i + '0';
write(1, &s, 1);
}
}
void moves_writer(t_list *p)
{
ft_putstr("you have moved ");
ft_putnbr(p->count);
ft_putstr(" moves\n");
}
void end_fct(t_list *p)
{
if (p->wall)
mlx_destroy_image(p->mlx, p->wall);
if (p->collectible)
mlx_destroy_image(p->mlx, p->collectible);
if (p->player)
mlx_destroy_image(p->mlx, p->player);
if (p->exit)
mlx_destroy_image(p->mlx, p->exit);
if (p->background)
mlx_destroy_image(p->mlx, p->background);
mlx_destroy_window(p->mlx, p->windw);
}