2022-12-22 11:41:31 -05:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* solong.h :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
2023-01-04 14:07:13 -05:00
|
|
|
/* Created: 2023/01/04 16:20:03 by cchauvet #+# #+# */
|
2023-01-16 12:38:47 -05:00
|
|
|
/* Updated: 2023/01/16 18:36:10 by cchauvet ### ########.fr */
|
2022-12-22 11:41:31 -05:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
#ifndef SOLONG_H
|
|
|
|
# define SOLONG_H
|
2023-01-16 12:38:47 -05:00
|
|
|
# include "../libftx/libftx.h"
|
2023-01-04 14:07:13 -05:00
|
|
|
# define XPM_PATH "./textures/"
|
|
|
|
# include <unistd.h>
|
|
|
|
# include <fcntl.h>
|
2023-01-16 12:38:47 -05:00
|
|
|
# include "../minilibx-linux/mlx.h"
|
2023-01-11 13:10:28 -05:00
|
|
|
# define CASE_SIZE 64
|
2023-01-06 13:37:36 -05:00
|
|
|
# define XPM_HEADER "\nstatic char * XFACE[] = {\""
|
2023-01-11 13:10:28 -05:00
|
|
|
# define COLORS "silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|aqua|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen"
|
2023-01-13 12:59:48 -05:00
|
|
|
# define NB_COLORS 93
|
2023-01-06 13:37:36 -05:00
|
|
|
# define RENDER_DISTANCE 5
|
|
|
|
# define WINDOW_SIZE (RENDER_DISTANCE * 2 + 1) * CASE_SIZE
|
2023-01-08 12:03:40 -05:00
|
|
|
|
|
|
|
typedef struct s_square
|
2023-01-04 14:07:13 -05:00
|
|
|
{
|
2022-12-22 11:41:31 -05:00
|
|
|
char *color;
|
2023-01-04 14:07:13 -05:00
|
|
|
size_t size;
|
2023-01-08 12:03:40 -05:00
|
|
|
} t_square;
|
2023-01-06 13:37:36 -05:00
|
|
|
|
|
|
|
typedef struct s_map
|
|
|
|
{
|
|
|
|
size_t x_len;
|
|
|
|
size_t y_len;
|
|
|
|
size_t nb_collectable;
|
|
|
|
char **patern;
|
2023-01-09 14:41:06 -05:00
|
|
|
size_t player_pos[2];
|
|
|
|
size_t exit_pos[2];
|
2023-01-06 13:37:36 -05:00
|
|
|
} t_map;
|
|
|
|
|
|
|
|
typedef struct s_data
|
|
|
|
{
|
|
|
|
void *mlx;
|
|
|
|
void *window;
|
2023-01-11 13:10:28 -05:00
|
|
|
void *assets[NB_COLORS * 2];
|
2023-01-09 14:41:06 -05:00
|
|
|
t_map *map;
|
2023-01-11 13:10:28 -05:00
|
|
|
size_t nb_swaps;
|
|
|
|
size_t nb_foots;
|
2023-01-06 13:37:36 -05:00
|
|
|
} t_data;
|
|
|
|
|
2023-01-13 09:10:27 -05:00
|
|
|
int ft_test_map_is_finishable(t_map *map);
|
2023-01-10 13:04:46 -05:00
|
|
|
int ft_exit(t_data *data);
|
2023-01-13 09:10:27 -05:00
|
|
|
int ft_test_map_content2(char **patern);
|
2023-01-09 14:41:06 -05:00
|
|
|
int ft_key(int key, t_data *data);
|
2023-01-13 09:10:27 -05:00
|
|
|
void ft_fill_pos(t_map *map);
|
2023-01-08 12:03:40 -05:00
|
|
|
char *name_generator(t_square square);
|
2023-01-06 13:37:36 -05:00
|
|
|
t_map *ft_getmap(char *path);
|
2023-01-11 13:10:28 -05:00
|
|
|
char *ft_xpm_gen_file(t_square square);
|
|
|
|
int ft_gen_assets(t_data *data);
|
2023-01-06 13:37:36 -05:00
|
|
|
char **ft_get_player_map(t_map map);
|
2023-01-09 14:41:06 -05:00
|
|
|
int ft_draw_map(t_data *data);
|
2023-01-08 12:03:40 -05:00
|
|
|
char *name_generator(t_square square);
|
|
|
|
int ft_color_changer(t_data *data);
|
2023-01-13 09:10:27 -05:00
|
|
|
void ft_draw_img(t_data *data, void *img, size_t x, size_t y);
|
2022-12-22 11:41:31 -05:00
|
|
|
#endif
|