diff options
author | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-29 20:09:29 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-29 20:09:29 +0100 |
commit | 99143755522989d11ee5dd9b42a665e2368c9481 (patch) | |
tree | fee854ebc0efa04766180eaf9bd5830261d0025c | |
parent | Perfect (diff) | |
download | 42-cub3d-99143755522989d11ee5dd9b42a665e2368c9481.tar.gz 42-cub3d-99143755522989d11ee5dd9b42a665e2368c9481.tar.bz2 42-cub3d-99143755522989d11ee5dd9b42a665e2368c9481.tar.xz 42-cub3d-99143755522989d11ee5dd9b42a665e2368c9481.tar.zst 42-cub3d-99143755522989d11ee5dd9b42a665e2368c9481.zip |
it's wonderful
-rw-r--r-- | src/ft_drawmap.c | 7 | ||||
-rw-r--r-- | src/ft_get_map_redo.c | 5 | ||||
-rw-r--r-- | src/ft_parse_map.c | 43 | ||||
-rw-r--r-- | src/ft_print_list.c | 1 |
4 files changed, 26 insertions, 30 deletions
diff --git a/src/ft_drawmap.c b/src/ft_drawmap.c index 3466df0..172a637 100644 --- a/src/ft_drawmap.c +++ b/src/ft_drawmap.c @@ -16,10 +16,13 @@ ft_drawmap(t_cub *clist) { if (clist->map[x][y] == '1') ft_drawsquare(40 + (y * 41), 40 + (x * 41), + 0x00aa99aa, clist); + else if (clist->map[x][y] == '0') + ft_drawsquare(40 + (y * 41), 40 + (x * 41), clist->f_color, clist); - if (clist->map[x][y] == '0') + else if (clist->map[x][y] == '2') ft_drawsquare(40 + (y * 41), 40 + (x * 41), - clist->c_color, clist); + 0x0033ccff, clist); y++; } y = 0; diff --git a/src/ft_get_map_redo.c b/src/ft_get_map_redo.c index be6f987..2f020f9 100644 --- a/src/ft_get_map_redo.c +++ b/src/ft_get_map_redo.c @@ -72,9 +72,10 @@ ft_get_map_core(int fd, t_cub *clist) { clist->line_chk += 1; ret = get_next_line(fd, &line); - if (ret < 0 || !line[0] || ft_check_map_line(line, 0, clist) < 0) + if (ret < 0) return (-1); - if (ft_cat_mapl(line, i, clist) < 0) + if (!line[0] || ft_check_map_line(line, 0, clist) < 0 + || ft_cat_mapl(line, i, clist) < 0) { ft_memdel(line); return (-1); diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index f51d531..77f3f47 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -30,23 +30,23 @@ ft_check_cub(const char *map_path, t_cub *clist) ft_free_words(words); } -/* static void */ -/* ft_check_map_last_line(t_cub *clist) */ -/* { */ -/* size_t i; */ -/* size_t j; */ +static void +ft_check_map_last_line(t_cub *clist) +{ + size_t i; + size_t j; -/* i = 0; */ -/* while (clist->map[i]) */ -/* i++; */ -/* j = 0; */ -/* while (clist->map[i - 1][j]) */ -/* { */ -/* if (clist->map[i - 1][j] != '1' && clist->map[i - 1][j] != '\0') */ -/* ft_map_error(clist); */ -/* j++; */ -/* } */ -/* } */ + i = 0; + while (clist->map[i]) + i++; + j = 0; + while (clist->map[i - 1][j]) + { + if (clist->map[i - 1][j] != '1' && clist->map[i - 1][j] != '\0') + ft_map_error(clist); + j++; + } +} static int8_t ft_parse_it(int fd, t_cub *clist) @@ -105,17 +105,8 @@ ft_parse_map(const char *map_path, t_cub *clist) clist->nsew = 0; if (ft_get_map_core(fd, clist) < 0) ft_map_error(clist); + ft_check_map_last_line(clist); ft_check_missing(clist); - /* if (ft_get_tex(fd, clist) < 0) */ - /* return ; */ - /* ft_check_empty_line(fd, 6, clist); */ - /* if (ft_get_sprite_tex(fd, clist) < 0) */ - /* return ; */ - /* ft_get_colors(fd, clist); */ - /* ft_check_empty_line(fd, 10, clist); */ - /* if (ft_get_map(fd, clist) < 0) */ - /* ft_map_error(11, clist); */ - /* ft_check_map_last_line(clist); */ ft_print_list(clist); close(fd); } diff --git a/src/ft_print_list.c b/src/ft_print_list.c index 495f9e4..92d8674 100644 --- a/src/ft_print_list.c +++ b/src/ft_print_list.c @@ -23,4 +23,5 @@ ft_print_list(t_cub *clist) i++; } ft_printf("Map width [%zu]\n", clist->map_w); + ft_printf("----------------------\n"); } |