From 0978388f4ae8f78c53ade14db1d5c1c8819e4310 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Mon, 27 Jan 2020 20:22:14 +0100 Subject: Nice map drawing --- inc/cub3d.h | 1 + map/map_one.cub | 2 +- src/ft_drawmap.c | 24 +++++++++++++++++++++--- src/main.c | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/inc/cub3d.h b/inc/cub3d.h index f0b8181..6b35fab 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -59,6 +59,7 @@ void ft_check_empty_line(int fd, void ft_free_words(char **words, char *line); int ft_map_error(unsigned int linum, t_cub *clist); int ft_init_winlx(t_cub *clist); +void ft_drawmap(t_cub *clist); void ft_print_list(t_cub *clist); #endif diff --git a/map/map_one.cub b/map/map_one.cub index df60d8f..e35fb76 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -1,4 +1,4 @@ -R 800 600 +R 1700 1000 NO ./path_to_the_north_texture SO ./path_to_the_south_texture WE ./path_to_the_west_texture diff --git a/src/ft_drawmap.c b/src/ft_drawmap.c index f944b11..c0854e0 100644 --- a/src/ft_drawmap.c +++ b/src/ft_drawmap.c @@ -1,7 +1,25 @@ #include +#include -int -ft_drawmap(void) +void +ft_drawmap(t_cub *clist) { - return (0); + int x; + int y; + + (void)clist; + x = 0; + y = 0; + while (clist->map[x]) + { + while (clist->map[x][y]) + { + if (clist->map[x][y] == '1') + ft_drawsquare(40 + (y * 41), 40 + (x * 41), + clist->f_color, clist); + y++; + } + y = 0; + x++; + } } diff --git a/src/main.c b/src/main.c index bca23ce..8c4ecb9 100644 --- a/src/main.c +++ b/src/main.c @@ -22,7 +22,7 @@ int if (ft_init_winlx(clist) < 0) return (ft_exit(3, clist)); mlx_key_hook(clist->wlist->winptr, ft_key_event, clist); - ft_drawsquare(80, 80, clist->f_color, clist); + ft_drawmap(clist); mlx_loop(clist->wlist->wlx); return (0); } -- cgit v1.2.3