/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* utils_4.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lfirmin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/17 13:04:09 by lfirmin #+# #+# */ /* Updated: 2024/11/17 13:04:09 by lfirmin ### ########.fr */ /* */ /* ************************************************************************** */ #include "../include/so_long.h" void init_struct(t_game *game) { game->mlx = NULL; game->win = NULL; game->img_floor = NULL; game->img_wall = NULL; game->img_player = NULL; game->img_collect = NULL; game->img_exit = NULL; game->player_x = 0; game->player_y = 0; game->moves = 0; game->collectibles = 0; game->map = NULL; game->map_width = 0; game->map_height = 0; game->exit_x = 0; game->exit_y = 0; game->data = NULL; } int get_map_2(int i, int nb_lines, t_data *data, int fd) { char *line; line = get_next_line(fd); while (line != NULL && i < nb_lines) { if (i == nb_lines - 1) line = add_newline_if_needed(line); if (!line) return (1); data->map[i++] = line; line = get_next_line(fd); } data->map[i] = NULL; return (0); } void find_exit_pos(t_game *game) { int x; int y; y = 0; while (y < game->map_height) { x = 0; while (x < game->map_width) { if (game->map[y][x] == 'E') { game->exit_x = x; game->exit_y = y; return ; } x++; } y++; } }