diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-02-04 23:45:21 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-02-04 23:45:21 +0100 |
commit | 20a7a10c762d2d81d3f749d08d4da3f56a045dce (patch) | |
tree | 0e04d3d6b0828b4b65e1bb4d49b464678492b03d /src | |
parent | Pretty good (diff) | |
download | 42-cub3d-20a7a10c762d2d81d3f749d08d4da3f56a045dce.tar.gz 42-cub3d-20a7a10c762d2d81d3f749d08d4da3f56a045dce.tar.bz2 42-cub3d-20a7a10c762d2d81d3f749d08d4da3f56a045dce.tar.xz 42-cub3d-20a7a10c762d2d81d3f749d08d4da3f56a045dce.tar.zst 42-cub3d-20a7a10c762d2d81d3f749d08d4da3f56a045dce.zip |
Scale
Diffstat (limited to '')
-rw-r--r-- | src/ft_drawmap.c | 21 | ||||
-rw-r--r-- | src/ft_drawsquare.c | 8 | ||||
-rw-r--r-- | src/ft_parse_map.c | 3 | ||||
-rw-r--r-- | src/ft_print_list.c | 1 |
4 files changed, 22 insertions, 11 deletions
diff --git a/src/ft_drawmap.c b/src/ft_drawmap.c index 698d852..02151a2 100644 --- a/src/ft_drawmap.c +++ b/src/ft_drawmap.c @@ -14,12 +14,14 @@ #include <libft.h> #include <cub3d.h> #include <mlx.h> +#include <stdint.h> static void ft_draw_core_map(char **map, t_cub *clist) { - size_t x; - size_t y; + const uint16_t scale = clist->scale; + size_t x; + size_t y; x = 0; y = 0; @@ -28,13 +30,13 @@ static void while (map[y][x]) { if (map[y][x] == '1') - ft_drawsquare(40 + (x * 41), 40 + (y * 41), + ft_drawsquare(scale + (x * (scale + 1)), scale + (y * (scale + 1)), 0x00aa99aa, clist); else if (map[y][x] == '2') - ft_drawsquare(40 + (x * 41), 40 + (y * 41), + ft_drawsquare(scale + (x * (scale + 1)), scale + (y * (scale + 1)), 0x0033ccff, clist); else - ft_drawsquare(40 + (x * 41), 40 + (y * 41), + ft_drawsquare(scale + (x * (scale + 1)), scale + (y * (scale + 1)), ft_rgb_to_hex(clist->f_rgb), clist); x++; } @@ -46,10 +48,13 @@ static void static void ft_draw_player(t_player *plist, t_cub *clist) { - const float x = plist->pos_x; - const float y = plist->pos_y; + const float x = plist->pos_x; + const float y = plist->pos_y; + const uint16_t scale = clist->scale; - ft_drawsquare(40 + (x * 41), 40 + (y * 41), 0x009843fa, clist); + ft_drawsquare(scale + (x * (scale + 1)), + scale + (y * (scale + 1)), + 0x009843fa, clist); } void diff --git a/src/ft_drawsquare.c b/src/ft_drawsquare.c index 1488c68..9e23937 100644 --- a/src/ft_drawsquare.c +++ b/src/ft_drawsquare.c @@ -11,20 +11,22 @@ /* / */ /* ************************************************************************** */ -#include <mlx.h> #include <cub3d.h> +#include <mlx.h> +#include <stdint.h> void ft_drawsquare(int a, int b, int rgb, t_cub *clist) { + const uint16_t scale = clist->scale; int x; int y; x = a; y = b; - while (x > a - 40) + while (x > a - scale) { - while (y > b - 40) + while (y > b - scale) { *(int*)(clist->img.ptr + (x * 4 + (y * clist->img.sizeline))) = rgb; y--; diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 29f2c43..f5e491f 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -16,6 +16,7 @@ #include <stdlib.h> #include <fcntl.h> #include <unistd.h> +#include <stdint.h> static void ft_check_cub(const char *map_path, t_cub *clist) @@ -118,6 +119,8 @@ void ft_check_map_last_line(clist); ft_get_player_spawn(clist->plist, clist); ft_check_missing(clist); + clist->scale = ((uint16_t)clist->wlist->x_size / + (uint16_t)clist->map_w) - 2; ft_print_list(clist); close(fd); } diff --git a/src/ft_print_list.c b/src/ft_print_list.c index 601a498..c459a11 100644 --- a/src/ft_print_list.c +++ b/src/ft_print_list.c @@ -36,5 +36,6 @@ void i++; } ft_printf("Map width -- [%zu]\n", clist->map_w); + ft_printf("2D scale --- [%hu]\n", clist->scale); ft_printf("----------------------\n"); } |