diff --git a/bonus/asset.c b/bonus/asset.c index d68b9eb..f7f9485 100644 --- a/bonus/asset.c +++ b/bonus/asset.c @@ -6,7 +6,7 @@ /* By: cchauvet assets[i] = ft_gen_asset(colors[i], CASE_SIZE, data); if (data->assets[i] == NULL) + { + ft_freer_tab_ultimate(1, colors); return (1); + } data->assets[i + NB_COLORS] = ft_gen_asset(colors[i], - WINDOW_SIZE, data); + (RENDER_DISTANCE * 2 + 1) * CASE_SIZE, data); + if (data->assets[i + NB_COLORS] == NULL) + ft_freer_tab_ultimate(1, colors); if (data->assets[i + NB_COLORS] == NULL) return (1); i++; diff --git a/bonus/draw.c b/bonus/draw.c index 2893dcf..e928073 100644 --- a/bonus/draw.c +++ b/bonus/draw.c @@ -6,7 +6,7 @@ /* By: cchauvet map); - data->nb_swaps = ++data->nb_swaps % NB_COLORS; + data->nb_swaps = ft_random_generator(0, NB_COLORS - 6); patern = ft_get_player_map(*data->map); if (patern == NULL) return (1); - ft_draw_img(data, data->assets[data->nb_swaps + NB_COLORS], 0, 0); + ft_draw_img(data, data->assets[data->nb_swaps % NB_COLORS + NB_COLORS], 0, + 0); tab[1] = -1; while (patern[++tab[1]] != NULL) { diff --git a/bonus/main.c b/bonus/main.c index ef2ebe7..5e34efe 100644 --- a/bonus/main.c +++ b/bonus/main.c @@ -6,7 +6,7 @@ /* By: cchauvet mlx = mlx_init(); ft_printf("Generating assets ..."); - ft_gen_assets(data); + if (ft_gen_assets(data)) + ft_exit(data); ft_printf("\rGenerating assets [FINISHED]\n"); data->map = map; - data->window = mlx_new_window(data->mlx, WINDOW_SIZE, WINDOW_SIZE, "long"); + data->window = mlx_new_window(data->mlx, + (RENDER_DISTANCE * 2 + 1) * CASE_SIZE, + (RENDER_DISTANCE * 2 + 1) * CASE_SIZE, "long"); data->nb_foots = 0; - data->nb_swaps = ft_random_generator(0, NB_COLORS); + data->nb_swaps = ft_random_generator(0, NB_COLORS - 6); ft_draw_map(data); mlx_hook(data->window, 17, (0L), ft_exit, data); mlx_hook(data->window, 2, (1L << 0), ft_key, data); diff --git a/bonus/solong.h b/bonus/solong.h index c180de1..364ca95 100644 --- a/bonus/solong.h +++ b/bonus/solong.h @@ -6,7 +6,7 @@ /* By: cchauvet # include # include "../minilibx-linux/mlx.h" -# define CASE_SIZE 64 +# define CASE_SIZE 128 # define XPM_HEADER "\nstatic char * XFACE[] = {\"" -# define COLORS "silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|aqua|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen" -# define NB_COLORS 93 -# define RENDER_DISTANCE 5 -# define WINDOW_SIZE (RENDER_DISTANCE * 2 + 1) * CASE_SIZE +# define RENDER_DISTANCE 4 +# define NB_COLORS 100 +# define HEX "0123456789abcdef" -typedef struct s_square +typedef struct s_square { char *color; size_t size; -} t_square; +} t_square; -typedef struct s_map +typedef struct s_map { size_t x_len; size_t y_len; @@ -38,9 +37,9 @@ typedef struct s_map char **patern; size_t player_pos[2]; size_t exit_pos[2]; -} t_map; +} t_map; -typedef struct s_data +typedef struct s_data { void *mlx; void *window; @@ -48,7 +47,7 @@ typedef struct s_data t_map *map; size_t nb_swaps; size_t nb_foots; -} t_data; +} t_data; int ft_test_map_is_finishable(t_map *map); int ft_exit(t_data *data); diff --git a/bonus/xpm.c b/bonus/xpm.c index 6743bb4..9631f5b 100644 --- a/bonus/xpm.c +++ b/bonus/xpm.c @@ -6,7 +6,7 @@ /* By: cchauvet # include "../libft/libft.h" +char *ft_ultoa_base(unsigned long long n, char *base); char *get_next_line(int fd); size_t ft_random_generator(size_t start, size_t stop); void ft_freer_tab_ultimate(size_t len, ...); diff --git a/libftx/extra/ft_tabrealloc-5f29f43f.o.tmp b/libftx/extra/ft_tabrealloc-5f29f43f.o.tmp new file mode 100644 index 0000000..e69de29 diff --git a/libftx/extra/ft_ultoa.o b/libftx/extra/ft_ultoa.o new file mode 100644 index 0000000..6786878 Binary files /dev/null and b/libftx/extra/ft_ultoa.o differ diff --git a/libftx/extra/ft_ultoa_base.c b/libftx/extra/ft_ultoa_base.c new file mode 100644 index 0000000..33933e5 --- /dev/null +++ b/libftx/extra/ft_ultoa_base.c @@ -0,0 +1,89 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ultoa_base.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet # include +char *ft_ultoa_base(unsigned long long n, char *base); int ft_printf(const char *format, ...); char *get_next_line(int fd); size_t ft_random_generator(size_t start, size_t stop); diff --git a/mandatory/asset.c b/mandatory/asset.c index 773d6fe..2958dc7 100644 --- a/mandatory/asset.c +++ b/mandatory/asset.c @@ -6,7 +6,7 @@ /* By: cchauvet assets[NB_COLORS] = ft_gen_asset(colors[i], - WINDOW_SIZE, data); + (RENDER_DISTANCE * 2 + 1) * CASE_SIZE, data); if (data->assets[NB_COLORS] == NULL) return (1); ft_freer_tab_ultimate(1, colors); diff --git a/mandatory/main.c b/mandatory/main.c index 8e0cc3e..408c66f 100644 --- a/mandatory/main.c +++ b/mandatory/main.c @@ -6,7 +6,7 @@ /* By: cchauvet map = map; - data->window = mlx_new_window(data->mlx, WINDOW_SIZE, WINDOW_SIZE, "long"); + data->window = mlx_new_window(data->mlx, + (RENDER_DISTANCE * 2 + 1) * CASE_SIZE, + (RENDER_DISTANCE * 2 + 1) * CASE_SIZE, "long"); ft_draw_map(data); mlx_hook(data->window, 17, (0L), ft_exit, data); mlx_hook(data->window, 2, (1L << 0), ft_key, data); diff --git a/mandatory/solong.h b/mandatory/solong.h index b46ce9b..e40b62c 100644 --- a/mandatory/solong.h +++ b/mandatory/solong.h @@ -6,7 +6,7 @@ /* By: cchauvet