-
Notifications
You must be signed in to change notification settings - Fork 0
/
solong.c
61 lines (55 loc) · 1.77 KB
/
solong.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* solong.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ofadhel <ofadhel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/09 20:59:04 by ofadhel #+# #+# */
/* Updated: 2023/04/25 16:52:32 by ofadhel ### ########.fr */
/* */
/* ************************************************************************** */
#include "solong.h"
void check_map_name(char *str)
{
int i;
i = ft_strlen(str);
if (str[i - 1] != 'r' || str[i - 2] != 'e' || str[i - 3] != 'b'
|| str[i - 4] != '.')
{
ft_printf("Error: map name must be .ber\n");
exit(1);
}
}
int close_game(t_game *game)
{
mlx_destroy_window(game->mlx, game->win);
free_map(game);
exit(1);
}
int main(int ac, char **av)
{
t_game game;
t_check check;
if (ac != 2)
{
ft_printf("Error: no map\n");
return (1);
}
check_map_name(av[1]);
game.map = read_map(av[1], &game);
check.map = read_map(av[1], &game);
init(&game, &check);
game.mlx = mlx_init();
map_size(&game, &check);
checks(&check, &game);
game.win = mlx_new_window(game.mlx, game.map_width,
game.map_height, "so_long");
xpm_img(&game);
set_win(&game);
mlx_key_hook(game.win, key, &game);
mlx_hook(game.win, 17, 0, close_game, &game);
mlx_loop(game.mlx);
free(game.mlx);
return (0);
}