/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   so_long_bonus.h                                    :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: erey-bet <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2022/12/10 17:59:18 by erey-bet          #+#    #+#             */
/*   Updated: 2023/01/09 19:33:31 by erey-bet         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef SO_LONG_BONUS_H
# define SO_LONG_BONUS_H

# include <X11/X.h>
# include "minilibx-linux/mlx.h"
# include "key.h" 
# include <stdlib.h>
# include "libft/libft.h"
# include "get_next_line/get_next_line.h"
# include <fcntl.h>
# include <math.h>

typedef struct s_img
{
	void	**ply;
	void	*bg;
	void	**wall;
	void	**col;
	void	**exit;
	void	*ene;
	void	*finish;
}	t_img;

typedef struct s_data
{
	void	*mlx;
	void	*mlx_win;
	char	**map;
	t_img	imgs;
	int		tick;
	int		h_map;
	int		w_map;
	int		update;
	int		size;
	int		x_ply;
	int		y_ply;
	int		x_ene;
	int		y_ene;
	int		h_scr;
	int		w_scr;
	int		move;
}	t_data;

typedef struct s_xy
{
	int	x;
	int	y;
}	t_xy;

// Init
void	if_spawn_enemy(t_data *data);
void	*mxfi(t_data *data, char *assets);
int		trgb(int t, int r, int g, int b);
int		ft_pow(int nb, int power);

// Map
char	*get_map(char *argv[], t_data *data);
int		init_fd_map(char *argv[], char **tmp_map, char **map, int *i);
void	read_map(char *argv[], t_data *data);
int		too_much(t_data *data);

// Render
int		render(t_data *data);
void	pre_draw(t_data *data);

// Player
void	move(t_data *data, int x, int y);
void	*set_position_player(t_data *data, t_xy *xy);

// Enemy
void	move_enemy(t_data *data);
int		ft_strslen(char **src);
int		choice(int **map, int *i, int x, int y);
void	finish(t_data *data);
int		dist(t_data *data);

// Position
t_xy	*get_position(char **map, char c);
int		has_element(char **map, char c);
char	get_element(t_data *data, t_xy xy);
void	set_element(t_data *data, int x, int y, char element);

// Quit
int		quit(t_data *data);
int		end(t_data *data);

#endif
