-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimap.c
72 lines (67 loc) · 1.87 KB
/
minimap.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
65
66
67
68
69
70
71
72
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minimap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zwalad <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/29 12:05:24 by zwalad #+# #+# */
/* Updated: 2023/01/05 02:05:10 by zwalad ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub1d.h"
void print_map(int j, int i, int color, t_big *p)
{
int x_next;
int y_next;
i += 1;
j += 1;
i *= 16;
j *= 16;
x_next = j + 16;
y_next = i + 16;
while (i < y_next)
{
j = x_next - 16;
while (j < x_next)
{
mlx_pixel_put(p->mlx.mlx_ptr, p->mlx.win_ptr, j, i, color);
j++;
}
i++;
}
}
int long_if(int i, int j, t_big *p)
{
if ((int)(i + (p->map.ip / SIZE)) <= 0
|| j + (p->map.jp / SIZE) >= \
ft_strlen(p->map.map[(int)(p->map.ip / SIZE) + i])
|| (int)(j + (p->map.jp / SIZE)) < 0)
{
return (1);
}
return (0);
}
void read_map(t_big *p, int i, int j)
{
while (i < 4)
{
if (!((i + (p->map.ip / SIZE)) >= p->map.i)
&& !((i + (p->map.ip / SIZE)) < 0))
{
j = -4;
while (j < 4)
{
if (long_if(i, j, p))
print_map(j, i, 0xAFF24405, p);
else if (p->map.map[(int)((p->map.ip / SIZE) + i)] \
[(int)((p->map.jp / SIZE) + j)] == '0')
print_map(j, i, 0xAF164773, p);
else
print_map(j, i, 0xAFF24405, p);
j++;
}
}
i++;
}
}