-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch_map.c
58 lines (53 loc) · 1.9 KB
/
launch_map.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* launch_map.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: melkholy <melkholy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/07 00:43:37 by melkholy #+# #+# */
/* Updated: 2022/10/07 22:23:43 by melkholy ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void ft_walk_through(t_graph *graph, int row, int col)
{
if (graph->cats != graph->awake)
{
ft_printf("You have to wake up all Kiwis!\n");
ft_change_position(graph, row, col);
}
else
{
ft_printf("Great Job! You Won :)\n");
ft_free_destroy(graph);
}
}
void ft_put_image(t_graph *graph, void *img, int row, int col)
{
mlx_put_image_to_window(graph->mlx, graph->win, \
img, IMG_SIZE * col, IMG_SIZE * row);
}
void ft_load_map(t_graph *graph)
{
int row;
int col;
row = -1;
while (++row < graph->row)
{
col = -1;
while (++col < graph->col)
{
if (graph->map[row][col] == '1')
ft_put_image(graph, graph->wall, row, col);
else if (graph->map[row][col] == '0')
ft_put_image(graph, graph->space, row, col);
else if (graph->map[row][col] == 'C')
ft_put_image(graph, graph->cat_img[0], row, col);
else if (graph->map[row][col] == 'P')
ft_put_image(graph, graph->ply_img, row, col);
else if (graph->map[row][col] == 'E')
ft_put_image(graph, graph->door[0], row, col);
}
}
}