This commit is contained in:
Camille Chauvet 2023-01-27 13:58:11 +01:00
parent a241d049c4
commit d4f3a72f76
3 changed files with 6 additions and 3 deletions

View File

@ -12,10 +12,11 @@
#include "solong.h"
static void ft_case_update(char *new_pos, char *player_pos)
static void ft_case_update(t_data *data, char *new_pos, char *player_pos)
{
*new_pos = 'P';
*player_pos = '0';
ft_printf("\r%d", ++data->nb_foots);
}
static void ft_move(t_data *data, char direction)
@ -36,7 +37,8 @@ static void ft_move(t_data *data, char direction)
if (*new_pos == 'C')
data->map->nb_collectable--;
if (*new_pos == '0' || *new_pos == 'C')
ft_case_update(new_pos, &data->map->patern[tab[1]][tab[0]]);
ft_case_update(data, new_pos,
&data->map->patern[tab[1]][tab[0]]);
if (*new_pos == 'E')
{
if (data->map->nb_collectable == 0)

View File

@ -76,6 +76,7 @@ int main(int ac, char **av)
}
data.map = NULL;
data.window = NULL;
data.nb_foots = 0;
if (ft_initialised(av[1], &data))
ft_printf("Memory error");
return (1);

View File

@ -44,10 +44,10 @@ typedef struct s_data
void *mlx;
void *window;
void *assets[NB_COLORS + 1];
size_t nb_foots;
t_map *map;
} t_data;
//void ft_ultimate_image_destroyer(t_data *data);
int ft_test_map_is_finishable(t_map *map);
int ft_exit(t_data *data);
int ft_test_map_content2(char **patern);