/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* so_long.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lfirmin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/12 11:00:04 by lfirmin #+# #+# */ /* Updated: 2024/11/17 13:53:20 by lfirmin ### ########.fr */ /* */ /* ************************************************************************** */ /* ************************************************************************** */ /* */ /* ::: :::::::: */ /* so_long.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lfirmin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/17 10:00:00 by lfirmin #+# #+# */ /* Updated: 2024/03/17 10:00:00 by lfirmin ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef SO_LONG_H # define SO_LONG_H # define KEY_ESC 65307 # define KEY_W 119 # define KEY_A 97 # define KEY_S 115 # define KEY_D 100 # define KEY_UP 65362 # define KEY_LEFT 65361 # define KEY_DOWN 65364 # define KEY_RIGHT 65363 # include "../minilibx-linux/mlx.h" # include "../gnl/include/get_next_line.h" # include "../libft/libft.h" # include "../ft_printf_fd/ftprintf.h" # include typedef struct s_data { char **map; int colect; int e; int p; } t_data; typedef struct s_game { void *mlx; void *win; void *img_floor; void *img_wall; void *img_player; void *img_collect; void *img_exit; int player_x; int player_y; int moves; int collectibles; char **map; int map_width; int map_height; int exit_x; int exit_y; t_data *data; } t_game; /* Utils functions */ t_data *init_data(void); void clean_data(t_data *data); int init_game(t_game *game); int find_player_pos(t_game *game); void draw_map(t_game *game); int close_game(t_game *game); void move_player(t_game *game, int new_x, int new_y); int is_valid_move(t_game *game, int x, int y); int key_hook(int keycode, t_game *game); void find_exit_pos(t_game *game); void draw_tile(t_game *game, char current, int x, int y); int init_images(t_game *game); int init_window(t_game *game); int check_player(t_game *game, int x, int y, int *found); void init_struct(t_game *game); /* Map parsing functions */ int get_map(char *filename, t_data *data); int ft_count_lines(char *file); int check_close(t_data *data); int check_rectangle(t_data *data); int check_playable(t_data *data); char **copy_map(char **original); int play_check(char **map, int x, int y); void free_map(char **map); int is_playable(t_data *data, int x, int y); int check_first_last_lines(t_data *data, int i); int pars_map(t_data *data, char *file); int have_require_item(t_data *data); char *add_newline_if_needed(char *line); int check_char(t_data *data); int is_ber(char *file); int get_map_2(int i, int nb_lines, t_data *data, int fd); /* in utils_4 */ #endif