-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimap.c
82 lines (73 loc) · 1.83 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
73
74
75
76
77
78
79
80
81
82
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minimap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: asegovia <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/21 11:03:25 by asegovia #+# #+# */
/* Updated: 2020/02/21 12:53:59 by asegovia ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
unsigned int chose_color(t_struct *t, int y, int x)
{
if (t->map.array[y][x] == 1)
return (0x45310a);
return (0xedf5f2);
}
void pixel_put(t_struct *t, int x, int y, int color)
{
t->img.data[y * t->map.rx + x] = color;
}
void paint_square(t_struct *t, unsigned int color, int x, int y)
{
int i;
int n;
i = 0;
while (i < 10)
{
n = 0;
while (n < 10)
{
pixel_put(t, (x + n), (y + i), color);
n++;
}
i++;
}
}
void paint_map(t_struct *t, int x, int y)
{
int col;
int row;
row = 0;
while (row != t->map.rows)
{
col = 0;
while (col != t->map.cols)
{
paint_square(t, chose_color(t, row, col),
(x + (10 * col)), (y + (10 * row)));
col++;
}
row++;
}
}
void paint_pos(t_struct *t)
{
int i;
int n;
i = 0;
while (i < 5)
{
n = 0;
while (n < 5)
{
pixel_put(t, (((t->mov.posx) * 10) + n - 3 +
(t->map.rx) - (10 * t->map.cols)), ((t->mov.posy * 10) + i - 3),
0x008000);
n++;
}
i++;
}
}