-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
64 lines (58 loc) · 2.04 KB
/
main.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
/* ************************************************************************** */
/* */
/* :::::::: */
/* main.c :+: :+: */
/* +:+ */
/* By: cschuijt <[email protected]> +#+ */
/* +#+ */
/* Created: 2022/11/11 14:28:55 by cschuijt #+# #+# */
/* Updated: 2022/11/11 14:28:55 by cschuijt ######## odam.nl */
/* */
/* ************************************************************************** */
#include "so_long.h"
#include <stdlib.h>
#include <unistd.h>
void print_map_data(t_map *map);
int main(int ac, char **av)
{
t_map *map;
if (ac != 2)
exit_message("please provide just the map file as a single argument");
map = initialize_map(av[1]);
ft_printf("Map seems good to me!\n");
map->mlx = mlx_init(32 * map->width, (32 * map->height) + GUI_OFFSET, \
"so_long", 0);
if (!map->mlx)
exit_message("couldn't initialize MLX window");
categorize_map_walls(map);
fill_in_background_sprite_indexes(map);
mlx_loop_hook(map->mlx, &animate_background_hook, map);
mlx_loop_hook(map->mlx, &animate_characters_hook, map);
mlx_loop_hook(map->mlx, &key_hook, map);
mlx_loop_hook(map->mlx, &endscreen_hook, map);
render_map(map);
mlx_loop(map->mlx);
detach_images_from_spritesheets(map);
mlx_terminate(map->mlx);
free_map_struct(map);
return (0);
}
void print_map_data(t_map *map)
{
size_t y;
y = 0;
while (y < map->height)
{
write(1, &map->content[y * map->width], map->width);
write(1, "\n", 1);
y++;
}
write(1, "\n", 1);
y = 0;
while (y < map->height)
{
write(1, &map->sprite_categories[y * map->width], map->width);
write(1, "\n", 1);
y++;
}
}