From 8b200fb8baf7d792220ca4e9de6d80ad92d470e5 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Thu, 19 Jan 2023 13:41:58 +0100 Subject: [PATCH] kekw --- bonus/asset.c | 34 ++++++++- bonus/draw.c | 7 +- bonus/main.c | 11 ++- bonus/solong.h | 23 +++--- bonus/xpm.c | 4 +- libftx/extra/Makefile | 4 +- libftx/extra/extra.h | 3 +- libftx/extra/ft_tabrealloc-5f29f43f.o.tmp | 0 libftx/extra/ft_ultoa.o | Bin 0 -> 4688 bytes libftx/extra/ft_ultoa_base.c | 89 ++++++++++++++++++++++ libftx/libftx.h | 3 +- mandatory/asset.c | 4 +- mandatory/main.c | 6 +- mandatory/solong.h | 15 ++-- maps/map_test.ber | 2 +- 15 files changed, 164 insertions(+), 41 deletions(-) create mode 100644 libftx/extra/ft_tabrealloc-5f29f43f.o.tmp create mode 100644 libftx/extra/ft_ultoa.o create mode 100644 libftx/extra/ft_ultoa_base.c 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 0000000000000000000000000000000000000000..6786878855dc45d6d962b41c0a3b72db00f17cfe GIT binary patch literal 4688 zcmb_fTWnNC7@l*^&e`p@-CYWD5dvGUG0It5Aqv*Ih>M4n8bU-HLuvPNw%xGZ#l190 zs5ae7C`}AJ7>zN8M_!EaL5LU$1|qE*ZIlNSQP&5_){w9y8mf@g|DQ9nm!UqG_%~-~ z{_ns4GiT29_0Z1ks-h4<3h5>_PN0PB^3>)*HVqOVXznp5e>02Mg68CC#hfgZ&Eja8 zc;9FR74uSP9yRCwKxS&RTwcJ*WT*s6C0XfPTd87B6-wppkiul>%2en|@w{Tj=FeeD zWq8nh7R+a5^W!MH6q;r_#nB4LTM(KGm5;gLclM}jt|pu4;WBV{9;B6ynaMBBn}rh0 z&mUXnLjyC`bH#kPXZq+ew6A>P29u8O%$qmB2C@uIo0!{VXnO9{!oq^E_`>1BptB&D zhjHF4UJUkKNEqIA6Bu6f%g_2XHCicu1z>TWcqbZKwjNMuSw+;$`l@=14N5Mi6e`!n z^4G`mt_#}n#M)d6m9UY}KkSe2r2;g!8Gqp6!ijdA)*6E`uxMC1R&;6ZvR!mZ1n;}x zUH1&H595KY_nci>iu*c7j)tzoBH2lRf;rVw@}6_JSpA#0mH@rydaiGtwwLiz=r$%k z_mHhq%i^@1MTMtTnVSFrv_X$dg>LsA{tn zXG`-F%@3~HvGl1`gg7WsIkaObA#`H{tKVrvh|^0@)pZ}yJl)OB&4e^92gLRZk;Wi% z2j)XuSOdXrc_*EORZum7KLDD_i^wV6FQL79;(*N^wz;92jH)LF7#ECz47k0F+gh-> zU5tAgy@1SQ+&0uC&2|YiB;3h~XPRb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&}nB<#ev8-!wBujiE)lnZ6u4{ZAb(lQetw|}SJDa=Lv0>*Q0vHn$BY>fe~ zi2cJeP}qz0$Madv2~AG%_`gU(i6w7??qczG@%=C2V0=tTjvoa~+qsZ|VGN!s4RL#M bCZRo&9RD(4a_>;@C=cZ41~}lBlH>maDPoK7 literal 0 HcmV?d00001 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