diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-02-06 19:02:34 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-02-06 19:02:34 +0100 |
commit | 3f95779e54a44ab15d566fbcbdc965d842d12786 (patch) | |
tree | d551e073e7306ce75d2e63d80bc2478fc87c9a3b | |
parent | xdpyinfo works on Linux (diff) | |
download | 42-cub3d-3f95779e54a44ab15d566fbcbdc965d842d12786.tar.gz 42-cub3d-3f95779e54a44ab15d566fbcbdc965d842d12786.tar.bz2 42-cub3d-3f95779e54a44ab15d566fbcbdc965d842d12786.tar.xz 42-cub3d-3f95779e54a44ab15d566fbcbdc965d842d12786.tar.zst 42-cub3d-3f95779e54a44ab15d566fbcbdc965d842d12786.zip |
New scale function
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | inc/cub3d.h | 1 | ||||
-rw-r--r-- | src/ft_parse_map.c | 3 | ||||
-rw-r--r-- | src/ft_set_minimap_scale.c | 10 |
4 files changed, 13 insertions, 2 deletions
@@ -30,6 +30,7 @@ SRCS_NAME += ft_get_sprite.c SRCS_NAME += ft_get_colors.c SRCS_NAME += ft_get_map.c SRCS_NAME += ft_get_player_spawn.c +SRCS_NAME += ft_set_minimap_scale.c SRCS_NAME += ft_check_missing.c SRCS_NAME += ft_check_map_line.c SRCS_NAME += ft_free_words.c diff --git a/inc/cub3d.h b/inc/cub3d.h index 0d1c8df..d83f7c0 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -144,6 +144,7 @@ int8_t ft_get_c_color(char **words, t_cub *clist); int ft_get_map_first_line(char *line, t_cub *clist); int ft_get_map_core(int fd, t_cub *clist); void ft_get_player_spawn(t_player *plist, t_cub *clist); +void ft_set_minimap_scale(t_cub *clist); int ft_check_missing(t_cub *clist); int8_t ft_check_map_line(char *line, uint8_t l, t_cub *clist); size_t ft_get_line_len(char *line); diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 85337f0..3014900 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -118,8 +118,7 @@ void ft_check_map_last_line(clist); ft_get_player_spawn(clist->plist, clist); ft_check_missing(clist); + ft_set_minimap_scale(clist); ft_print_list(clist); - ((clist->scale = ((uint16_t)clist->wlist->x_size / - (uint16_t)clist->map_w) - 1) < 1) ? (clist->scale = 1) : 0; close(fd); } diff --git a/src/ft_set_minimap_scale.c b/src/ft_set_minimap_scale.c new file mode 100644 index 0000000..5a69c18 --- /dev/null +++ b/src/ft_set_minimap_scale.c @@ -0,0 +1,10 @@ +#include <cub3d.h> + +void + ft_set_minimap_scale(t_cub *clist) +{ + ((clist->scale = (clist->wlist->x_size / (uint16_t)clist->map_w) - 1) < 1) + ? (clist->scale = 1) : 0; + (clist->wlist->y_size < (clist->map_h * clist->scale)) ? (clist->scale = + (clist->wlist->y_size / (uint16_t)clist->map_h) - 1) : 0; +} |