/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_draw_map.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:22:18 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:23:42 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include 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 float x = plist->pos_x; const float y = plist->pos_y; const uint16_t scale = clist->mlist->scale; ft_draw_circle( (scale / 2) + (x * (scale)), ft_y_offset(clist) - (scale) + (y * (scale)), 0x009843fa, clist); } void ft_draw_map(char **map, t_cub *clist) { const uint8_t scale = clist->mlist->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)), ft_y_offset(clist) + (y * (scale)), 0x0000ffaa, clist); else if (map[y][x] == '2') ft_draw_square(scale + (x * (scale)), ft_y_offset(clist) + (y * (scale)), 0x0033ccff, clist); else ft_draw_square(scale + (x * (scale)), ft_y_offset(clist) + (y * (scale)), ft_rgb_to_hex(clist->f_rgb), clist); x++; } x = 0; y++; } ft_draw_player(clist->plist, clist); }