Compare commits

..

No commits in common. "7d7de10b7aa5dd7d43e0d89c0ff587c2f76647f1" and "b66f8d6f5a940890e09e26177144f773071dd865" have entirely different histories.

5 changed files with 33 additions and 20 deletions

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/13 15:49:23 by cchauvet #+# #+# */ /* Created: 2022/12/13 15:49:23 by cchauvet #+# #+# */
/* Updated: 2023/01/16 18:46:55 by cchauvet ### ########.fr */ /* Updated: 2023/01/16 12:52:30 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -28,7 +28,7 @@ static void *ft_char2img(t_data *data, char c)
return (data->assets[data->nb_swaps + 3 % NB_COLORS]); return (data->assets[data->nb_swaps + 3 % NB_COLORS]);
if (c == 'P') if (c == 'P')
return (data->assets[data->nb_swaps + 4 % NB_COLORS]); return (data->assets[data->nb_swaps + 4 % NB_COLORS]);
if (c == 'B') if (c == 'B' && BONUS)
return (data->assets[data->nb_swaps + 5 % NB_COLORS]); return (data->assets[data->nb_swaps + 5 % NB_COLORS]);
return (NULL); return (NULL);
} }
@ -37,16 +37,19 @@ static void ft_draw_foots(t_data *data)
{ {
char *foots; char *foots;
data->nb_foots++; if (BONUS)
foots = ft_itoa(data->nb_foots);
if (foots == NULL)
{ {
ft_printf("Memory error\n"); data->nb_foots++;
ft_exit(data); foots = ft_itoa(data->nb_foots);
if (foots == NULL)
{
ft_printf("Memory error\n");
ft_exit(data);
}
mlx_string_put(data->mlx, data->window, 10, 10, 255, foots);
ft_printf("\r%s", foots);
free(foots);
} }
mlx_string_put(data->mlx, data->window, 10, 10, 255, foots);
ft_printf("\r%s", foots);
free(foots);
} }
int ft_draw_map(t_data *data) int ft_draw_map(t_data *data)
@ -56,7 +59,8 @@ int ft_draw_map(t_data *data)
void *img; void *img;
ft_fill_pos(data->map); ft_fill_pos(data->map);
data->nb_swaps = ++data->nb_swaps % NB_COLORS; if (BONUS)
data->nb_swaps = ++data->nb_swaps % NB_COLORS;
patern = ft_get_player_map(*data->map); patern = ft_get_player_map(*data->map);
if (patern == NULL) if (patern == NULL)
return (1); return (1);

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/12 17:20:17 by cchauvet #+# #+# */ /* Created: 2022/12/12 17:20:17 by cchauvet #+# #+# */
/* Updated: 2023/01/16 18:47:20 by cchauvet ### ########.fr */ /* Updated: 2023/01/13 18:50:00 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -29,7 +29,9 @@ int ft_initialised(char *path, t_data *data)
data->map = map; data->map = map;
data->window = mlx_new_window(data->mlx, WINDOW_SIZE, WINDOW_SIZE, "long"); data->window = mlx_new_window(data->mlx, WINDOW_SIZE, WINDOW_SIZE, "long");
data->nb_foots = 0; data->nb_foots = 0;
data->nb_swaps = ft_random_generator(0, NB_COLORS); data->nb_swaps = 35;
if (BONUS)
data->nb_swaps = ft_random_generator(0, NB_COLORS);
ft_draw_map(data); ft_draw_map(data);
mlx_hook(data->window, 17, (0L), ft_exit, data); mlx_hook(data->window, 17, (0L), ft_exit, data);
mlx_hook(data->window, 2, (1L << 0), ft_key, data); mlx_hook(data->window, 2, (1L << 0), ft_key, data);

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/05 20:14:44 by cchauvet #+# #+# */ /* Created: 2023/01/05 20:14:44 by cchauvet #+# #+# */
/* Updated: 2023/01/16 18:48:43 by cchauvet ### ########.fr */ /* Updated: 2023/01/13 15:47:42 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -43,7 +43,9 @@ int ft_test_map_content1(t_map *map)
x = 0; x = 0;
while (x < map->x_len) while (x < map->x_len)
{ {
if (ft_is_in("01CEPB", map->patern[y][x]) == 0) if (!BONUS && ft_is_in("01CEP", map->patern[y][x]) == 0)
return (0);
if (BONUS && ft_is_in("01CEPB", map->patern[y][x]) == 0)
return (0); return (0);
if (map->patern[y][x] == 'C') if (map->patern[y][x] == 'C')
nb_collectable++; nb_collectable++;

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/12 16:17:20 by cchauvet #+# #+# */ /* Created: 2023/01/12 16:17:20 by cchauvet #+# #+# */
/* Updated: 2023/01/16 18:48:20 by cchauvet ### ########.fr */ /* Updated: 2023/01/13 16:28:34 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,8 +14,14 @@
static void ft_collector(char **patern, size_t x, size_t y) static void ft_collector(char **patern, size_t x, size_t y)
{ {
if (ft_is_in("1B", patern[y][x])) if (BONUS)
return ; {
if (ft_is_in("1B", patern[y][x]))
return ;
}
else
if (patern[y][x] == '1')
return ;
patern[y][x] = '1'; patern[y][x] = '1';
ft_collector(patern, x, y - 1); ft_collector(patern, x, y - 1);
ft_collector(patern, x + 1, y); ft_collector(patern, x + 1, y);

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 16:20:03 by cchauvet #+# #+# */ /* Created: 2023/01/04 16:20:03 by cchauvet #+# #+# */
/* Updated: 2023/01/16 18:47:59 by cchauvet ### ########.fr */ /* Updated: 2023/01/16 18:36:10 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -64,5 +64,4 @@ int ft_draw_map(t_data *data);
char *name_generator(t_square square); char *name_generator(t_square square);
int ft_color_changer(t_data *data); int ft_color_changer(t_data *data);
void ft_draw_img(t_data *data, void *img, size_t x, size_t y); void ft_draw_img(t_data *data, void *img, size_t x, size_t y);
int ft_map_is_correct(t_map *map);
#endif #endif