-
Notifications
You must be signed in to change notification settings - Fork 2
/
render.c
executable file
·58 lines (53 loc) · 1.77 KB
/
render.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* render.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abenheni <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 14:02:15 by abenheni #+# #+# */
/* Updated: 2023/02/15 14:02:17 by abenheni ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
static void norm_help(t_long *data, t_help *dt, int f, int a)
{
int flag;
flag = 0;
if (data->map[f][a] == '1')
flag = mlx_put_image_to_window(data->mlx,
data->wind, data->img[0], a * 30, f * 30);
else if (data->map[f][a] == 'C')
flag = mlx_put_image_to_window(data->mlx,
data->wind, data->img[1], a * 30, f * 30);
else if (data->map[f][a] == 'P' && dt->fx == -1)
{
dt->fx = a * 30;
dt->fy = f * 30;
flag = mlx_put_image_to_window(data->mlx,
data->wind, data->img[2], a * 30, f * 30);
}
else if (data->map[f][a] == 'E')
{
flag = mlx_put_image_to_window(data->mlx,
data->wind, data->img[3], a * 30, f * 30);
}
if (flag == -1)
ft_error("error function returns -1\n");
}
void render_map(t_long *data, t_help *dt)
{
int f;
int a;
f = 0;
while (f < data->height)
{
a = 0;
while (a < data->width)
{
norm_help(data, dt, f, a);
a++;
}
f++;
}
}