aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_map.c
blob: e32b4e9893325f4e90f476a7b23d0f9135b017d6 (plain)
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
#include <cub3d.h>
#include <stdint.h>

static void
	ft_draw_player(t_player *plist, t_cub *clist)
{
	const float		x = plist->pos_x;
	const float		y = plist->pos_y - 1;
	const uint16_t	scale = clist->scale;

	ft_draw_square(
				scale + (x * (scale)),
				scale + (y * (scale)),
				0x009843fa,
				clist);
}

void
	ft_draw_map(char **map, t_cub *clist)
{
	const uint8_t	scale = clist->scale;
	size_t			x;
	size_t			y;

	x = 0;
	y = 0;
	while (map[y])
	{
		while (map[y][x])
		{
			if (map[y][x] == '1')
				ft_draw_square(scale + (x * (scale)),
								scale + (y * (scale)), 0x00aa99aa, clist);
			else if (map[y][x] == '2')
				ft_draw_square(scale + (x * (scale)),
								scale + (y * (scale)), 0x0033ccff, clist);
			else
				ft_draw_square(scale + (x * (scale)), scale + (y * (scale)),
					ft_rgb_to_hex(clist->f_rgb), clist);
			x++;
		}
		x = 0;
		y++;
	}
	ft_draw_player(clist->plist, clist);
}