diff options
author | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-02-02 19:21:05 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-02-02 19:21:05 +0100 |
commit | 93809613f9dcec51d02871de0f3b2e1025e34474 (patch) | |
tree | dd1a155fc23f1434ec0a0bb86a6b3789a59e8971 /src/ft_drawmap.c | |
parent | Parsed player spawn (diff) | |
download | 42-cub3d-93809613f9dcec51d02871de0f3b2e1025e34474.tar.gz 42-cub3d-93809613f9dcec51d02871de0f3b2e1025e34474.tar.bz2 42-cub3d-93809613f9dcec51d02871de0f3b2e1025e34474.tar.xz 42-cub3d-93809613f9dcec51d02871de0f3b2e1025e34474.tar.zst 42-cub3d-93809613f9dcec51d02871de0f3b2e1025e34474.zip |
Ain't bad
Diffstat (limited to 'src/ft_drawmap.c')
-rw-r--r-- | src/ft_drawmap.c | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/src/ft_drawmap.c b/src/ft_drawmap.c index 4063695..e1ad736 100644 --- a/src/ft_drawmap.c +++ b/src/ft_drawmap.c @@ -13,32 +13,49 @@ #include <libft.h> #include <cub3d.h> +#include <mlx.h> -void - ft_drawmap(t_cub *clist) +static void + ft_draw_core_map(char **map, t_cub *clist) { - int x; - int y; + size_t x; + size_t y; - (void)clist; x = 0; y = 0; - while (clist->map[x]) + while (map[y]) { - while (clist->map[x][y]) + while (map[y][x]) { - if (clist->map[x][y] == '1') - ft_drawsquare(40 + (y * 41), 40 + (x * 41), + if (map[y][x] == '1') + ft_drawsquare(40 + (x * 41), 40 + (y * 41), 0x00aa99aa, clist); - else if (clist->map[x][y] == '0') - ft_drawsquare(40 + (y * 41), 40 + (x * 41), + else if (map[y][x] == '0') + ft_drawsquare(40 + (x * 41), 40 + (y * 41), clist->f_color, clist); - else if (clist->map[x][y] == '2') - ft_drawsquare(40 + (y * 41), 40 + (x * 41), + else if (map[y][x] == '2') + ft_drawsquare(40 + (x * 41), 40 + (y * 41), 0x0033ccff, clist); - y++; + x++; } - y = 0; - x++; + x = 0; + y++; } } + +static void + ft_draw_player(t_player *plist, t_cub *clist) +{ + const size_t x = plist->pos_x; + const size_t y = plist->pos_y; + + ft_drawsquare(40 + (x * 41), 40 + (y * 41), 0x000077ff, clist); +} + +void + ft_drawmap(t_cub *clist) +{ + mlx_clear_window(clist->wlist->wlx, clist->wlist->winptr); + ft_draw_core_map(clist->map, clist); + ft_draw_player(clist->plist, clist); +} |