-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_start.c
More file actions
45 lines (41 loc) · 1.53 KB
/
ft_start.c
File metadata and controls
45 lines (41 loc) · 1.53 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_start.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yel-mota <yel-mota@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/09 08:17:41 by yel-mota #+# #+# */
/* Updated: 2025/04/09 23:05:11 by yel-mota ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
static int ft_maplen(char **map)
{
int i;
i = 0;
while (map[i])
i++;
return (i);
}
void ft_start(t_data *data)
{
data->y_init = mlx_init();
if (!data->y_init)
{
ft_error_close(ft_free_map(data->map), INIT_ERROR, -1);
}
data->y_wind = mlx_new_window(data->y_init, ft_strlen(data->map[0]) * HIGHT,
ft_maplen(data->map) * WIDTH, GAME_NAME);
if (!data->y_wind)
{
ft_free_map(data->map);
ft_putstr_fd(WINDOW_ERROR, 2);
ft_free_1(data->y_init, NULL, 1);
}
ft_putxpm(data);
ft_putimage(data);
mlx_hook(data->y_wind, 2, 1L << 0, key_handler, data);
mlx_hook(data->y_wind, 17, 0, close_wind, data);
mlx_loop(data->y_init);
}