diff options
-rw-r--r-- | src/ft_drawmap.c | 49 | ||||
-rw-r--r-- | src/ft_get_player_spawn.c | 4 |
2 files changed, 35 insertions, 18 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); +} diff --git a/src/ft_get_player_spawn.c b/src/ft_get_player_spawn.c index cb6dfcf..7b37d23 100644 --- a/src/ft_get_player_spawn.c +++ b/src/ft_get_player_spawn.c @@ -43,8 +43,8 @@ void { if (ft_ischarset("NSEW", clist->map[y][x])) { - plist->pos_x = x + 1; - plist->pos_y = y + 1; + plist->pos_x = x; + plist->pos_y = y; plist->view_side = ft_get_view_side(clist->map[y][x]); return ; } |