-
Notifications
You must be signed in to change notification settings - Fork 0
/
so_long.c
50 lines (45 loc) · 1.12 KB
/
so_long.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
#include "so_long.h"
static void mlx_help(t_data *data)
{
mlx_put_image_to_window(data->mlx, data->mlx_win, data->img.img, 0, 0);
mlx_hook(data->mlx_win, BUTTONPRESS, (1L << 0), ft_movplayer, data);
mlx_hook(data->mlx_win, DESTROYPRESS, 0L, ft_destroywindown, data);
mlx_loop(data->mlx);
}
static void help_main(t_data *data)
{
if (data->first != 1)
{
write (1, "Error\n", 6);
ft_destroywindown(data);
}
data->img.addr = (unsigned int *)mlx_get_data_addr(&data->img.img,
&(data->img.bits_per_pixel),
&(data->img.line_length), &(data->img.endian));
mlx_help(data);
}
int main(int ac, char **av)
{
t_data data;
if (ac == 2)
{
ft_bzero(&data, sizeof(data));
data.first = 0;
data.mv = 0;
if ((parse(av[1], &data) == 1) || (data.w * TS > 3200 || data.h > 1760))
{
write (1, "Error\n", 6);
return (1);
}
data.mlx = mlx_init();
data.mlx_win = mlx_new_window(data.mlx, data.w * TS, data.h * TS,
"######KHMIRA world!######");
data.img.img = mlx_new_image(data.mlx, data.w * TS, data.h * TS);
texture(&data);
draw(&data);
help_main(&data);
}
else
write (1, "Error\n", 6);
return (0);
}