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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_draw_map.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: joelecle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:22:18 by joelecle #+# #+# */
/* Updated: 2020/02/14 17:23:42 by joelecle ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <stdint.h>
static uint16_t
ft_y_offset(t_cub *clist)
{
return (clist->wlist.y_size
- (clist->mlist.map_h * clist->mlist.scale)
+ clist->mlist.scale - 1);
}
static void
ft_draw_player(t_player *plist, t_cub *clist)
{
const uint16_t scale = clist->mlist.scale;
const float x = plist->pos_x;
const float y = plist->pos_y;
ft_draw_circle(
(scale / 2) + (x * (scale)),
ft_y_offset(clist) - (scale + 9) + (y * (scale)),
0x009843fa,
clist);
}
void
ft_draw_map(char **map, t_cub *clist)
{
size_t x;
size_t y;
const uint8_t scale = clist->mlist.scale;
x = 0;
y = 0;
while (map[y])
{
while (map[y][x])
{
if (ft_ischarset("1", map[y][x]))
ft_draw_square(scale + 9 + (x * (scale)),
ft_y_offset(clist) - 9 + (y * (scale)), 0x00ca5422, clist);
else if (ft_ischarset(FT_CHRST_SPRITES, map[y][x]))
ft_draw_square(scale + 9 + (x * (scale)),
ft_y_offset(clist) - 9 + (y * (scale)), 0x0033ccff, clist);
else if (ft_ischarset(FT_CHRST_MAP_NON_WALL, map[y][x]))
ft_draw_square(scale + 9 + (x * (scale)), ft_y_offset(clist)
- 9 + (y * (scale)), 0x006afa6a, clist);
x++;
}
x = 0;
y++;
}
ft_draw_player(&clist->plist, clist);
}
|