diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c3f5a0b --- /dev/null +++ b/Makefile @@ -0,0 +1,138 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: rparodi +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2023/11/12 11:05:05 by rparodi #+# #+# # +# Updated: 2024/03/08 14:28:29 by rparodi ### ########.fr # +# # +# **************************************************************************** # +# Variables + +# Name +NAME = so_long +LIBDIRNAME = libft +SRCDIRNAME = sources + +# Commands +CC = cc +RM = rm -rf + +# Flags +CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD +MINILIBX = make -C ./minilibx-linux/ +MLXFLAGS = -Lmlx_linux -L/usr/lib -lXext -lX11 -lm -lz + +# Sources +LIB = ./libft/ft_printf.c \ + ./libft/ft_put.c \ + ./libft/ft_reverse_split.c \ + ./libft/ft_split.c \ + ./libft/ft_strdup.c \ + ./libft/ft_strlcpy.c \ + ./libft/get_next_line.c \ + ./libft/get_next_line_utils.c + +SRC = ./sources/ft_check_map.c \ + ./sources/ft_exit.c \ + ./sources/ft_init.c \ + ./sources/ft_map.c \ + ./sources/ft_move.c \ + ./sources/ft_parse_map.c \ + ./sources/ft_value.c \ + ./sources/main.c + +# Objects +MLXDIRNAME = ./minilibx-linux +MLX = $(MLXDIRNAME)/libmlx.a +OBJDIRNAME = ./object +OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o)) +LIB_OBJ = $(addprefix $(OBJDIRNAME)/,$(LIB:.c=.o)) + +# Colors +GREEN = \033[32m +GREY = \033[0;90m +RED = \033[0;31m +GOLD = \033[38;5;220m +END = \033[0m + +# Rules + +# All (make all) +all: header $(NAME) bonus footer + +# Bonus (make bonus) +bonus: $(OBJ) $(LIB_OBJ) + @make -C ./minilibx-linux >/dev/null 2>&1 + @cc $(CFLAGS) $(MLXFLAGS) -o $(NAME) $(OBJ) $(LIB_OBJ) ./minilibx-linux/libmlx.a + +# Clean (make clean) +clean: + @printf '$(GREY) Removing $(END)$(RED)Objects Folder$(END)\n' + @$(RM) $(OBJDIRNAME) + @printf '$(GREY) Removing $(END)$(RED)Object$(END)\n' + + +# Clean (make fclean) +fclean: clean + @printf '$(GREY) Removing $(END)$(RED)Program$(END)\n' + @$(RM) $(NAME) + @printf '$(GREY) Removing $(END)$(RED)Program MLX$(END)\n' + @$(RM) $(MLX) + @echo "" + +# Restart (make re) +re: header fclean bonus all + +# Dependences for all +$(NAME): $(OBJ) $(LIB_OBJ) + @mkdir -p $(OBJDIRNAME) + @mkdir -p $(OBJDIRNAME)/$(LIBDIRNAME) + @mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME) + @make -C ./minilibx-linux > /dev/null 2>&1 + @printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n' + @cc $(CFLAGS) $(MLXFLAGS) -o $(NAME) $(OBJ) $(LIB_OBJ) ./minilibx-linux/libmlx.a + +# Creating the objects +$(OBJDIRNAME)/%.o: %.c + @mkdir -p $(dir $@) + @printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n' + @cc $(CFLAGS) -o $@ -c $< + +# Header +header: + @clear + @printf '\n\n' + @printf '$(GOLD) ******* ****** ******* $(END)\n' + @printf '$(GOLD) ****** *** ******* $(END)\n' + @printf '$(GOLD) ******* * ******* $(END)\n' + @printf '$(GOLD) ****** ******* $(END)\n' + @printf '$(GOLD) ******* ******* $(END)\n' + @printf '$(GOLD) ******************* ******* * $(END)\n' + @printf '$(GOLD) ******************* ******* *** $(END)\n' + @printf '$(GOLD) ****** ******* ****** $(END)\n' + @printf '$(GOLD) ****** $(END)\n' + @printf '$(GOLD) ****** $(END)\n' + @printf '$(GREY) Made by rparodi$(END)\n\n' + +# Footer +footer: + @printf "\n" + @printf "$(GOLD) ,_ _,$(END)\n" + @printf "$(GOLD) | \\___//|$(END)\n" + @printf "$(GOLD) |=6 6=|$(END)\n" + @printf "$(GOLD) \\=._Y_.=/$(END)\n" + @printf "$(GOLD) ) \` ( ,$(END)\n" + @printf "$(GOLD) / \\ (('$(END)\n" + @printf "$(GOLD) | | ))$(END)\n" + @printf "$(GOLD) /| | | |\\_//$(END)\n" + @printf "$(GOLD) \\| |._.| |/-\`$(END)\n" + @printf "$(GOLD) '\"' '\"'$(END)\n" + @printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n' + +# Phony +.PHONY: all bonus clean fclean re + +-include ${OBJ:.o=.d} diff --git a/includes/so_long.h b/includes/so_long.h new file mode 100644 index 0000000..cb02ca1 --- /dev/null +++ b/includes/so_long.h @@ -0,0 +1,125 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* so_long.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/29 16:06:54 by rparodi #+# #+# */ +/* Updated: 2024/03/07 11:08:43 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef SO_LONG_H +# define SO_LONG_H + +# ifndef BUFFER_SIZE +# define BUFFER_SIZE 420 +# endif + +# define HAUTEUR 1920 +# define LONGUEUR 1080 + +# include "../minilibx-linux/mlx.h" +# include +# include +# include +# include +# include +# include +# include + +typedef struct s_image +{ + void *img_ptr; + char *addr; + int h; + int w; + int bpp; + int endian; + int line_len; +} t_image; + +typedef struct s_img_store +{ + t_image wall; + t_image floor; + t_image lock; + t_image open; + t_image player; + t_image coins; +} t_img_store; + +typedef struct s_mlx +{ + void *init; + void *window; + int w_h; + int w_l; + int fd_map; + size_t size_map; + char **map; + size_t map_h; + size_t map_l; + t_image *img; + unsigned int count; + char *path; + t_img_store store; +} t_mlx; + +char *ft_get_line(char *str); +char *get_next_line(int fd); +char *ft_get_next(char *str); +int ft_index_strchr(const char *s, char c); +char **ft_strsdup(char **s, t_mlx *mlx); +char *ft_get_line(char *str); +char *ft_strjoin(char *s1, char *s2, int i, int j); +char *file_converted(int fd); +char *ft_free(char *str); +char *ft_check(char *memory, int fd); +size_t ft_count_line(char *path); +int ft_printf(const char *str, ...); +int ft_check_args(char c, va_list args, int *ret_value); +void ft_putnbr_unsigned(unsigned int nb, int *ret_value); +void ft_putnbr(int nb, int *ret_value); +void ft_putchar(char c, int *ret_value); +void ft_putstr(char *str, int *ret_value); +size_t ft_strlcpy(char *dst, const char *src, size_t size); +size_t ft_strlen(const char *s); +size_t what_is_it(char *str, size_t i, size_t line, t_mlx *mlx); +char **ft_split(char const *s, char c); +int check_border(char *str, t_mlx *mlx); +char *size_file(t_mlx *mlx); +size_t ft_linelen(t_mlx *mlx); +void check_args(int argc, char *argv[], t_mlx *mlx); +void ft_exit(t_mlx *mlx, void *p2, short int exit_status, + char *error_msg); +t_image new_img(int w, int h, t_mlx *mlx); +void ft_parsing(char *str, t_mlx *mlx); +char *ft_strdup(const char *s); +int ft_close(t_mlx *mlx); +char ft_strchr(const char *s, int c); +void ft_free_maps(char **strs, char **copy); +int key_hook(int keycode, t_mlx *mlx); +t_image load_image(t_mlx *mlx, char *path); +t_mlx *ft_init_mlx(t_mlx *mlx, int argc, char **argv); +int main(int argc, char *argv[]); +void map_size(t_mlx *mlx); +t_image ft_whitch_case(char c, t_mlx *mlx); +char **ft_init_map(t_mlx *mlx, char *path); +size_t ft_strslen(char **strs); +char *ft_convert_strs_to_str(char *str, char **strs); +char *ft_reverse_split(t_mlx *mlx); +void ft_move_up(int x, int y, t_mlx *mlx, unsigned int *count); +void ft_move_down(int x, int y, t_mlx *mlx, unsigned int *count); +void ft_move_left(int x, int y, t_mlx *mlx, unsigned int *count); +void ft_move_right(int x, int y, t_mlx *mlx, unsigned int *count); +void ft_check_end(t_mlx *mlx, unsigned int coins); +void display_map(t_mlx *mlx); +void ft_free_image(t_mlx *mlx); +void ft_init_value_mlx(t_mlx *mlx); +unsigned int count_coins(t_mlx *mlx); +void ft_putnbr_base(unsigned long long nbr, char *base, + int *ret_value, char c); + +#endif diff --git a/libft/ft_printf.c b/libft/ft_printf.c new file mode 100644 index 0000000..b97e924 --- /dev/null +++ b/libft/ft_printf.c @@ -0,0 +1,64 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/14 17:27:44 by rparodi #+# #+# */ +/* Updated: 2024/03/06 11:25:24 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +int ft_check_args(char c, va_list args, int *ret_value) +{ + if (c == 'c') + ft_putchar((char)va_arg(args, int), ret_value); + else if (c == 's') + ft_putstr((char *)va_arg(args, char *), ret_value); + else if (c == 'i' || c == 'd') + ft_putnbr((int)va_arg(args, int), ret_value); + else if (c == '%') + ft_putchar('%', ret_value); + else if (c == 'u') + ft_putnbr_unsigned((unsigned int)va_arg(args, unsigned int), ret_value); + else if (c == 'x') + ft_putnbr_base((unsigned int)va_arg(args, unsigned int), + "0123456789abcdef", ret_value, c); + else if (c == 'X') + ft_putnbr_base((unsigned int)va_arg(args, unsigned int), + "0123456789ABCDEF", ret_value, c); + else if (c == 'p') + ft_putnbr_base((unsigned long long)va_arg(args, unsigned long long), + "0123456789abcdef", ret_value, c); + va_end(args); + return (1); +} + +int ft_printf(const char *s, ...) +{ + size_t i; + va_list args; + char *str; + int ret_value; + + ret_value = 0; + str = ft_strdup(s); + va_start(args, s); + i = 0; + while (str[i]) + { + if (str[i] == '%') + { + ft_check_args(str[i + 1], args, &ret_value); + i++; + } + else + ft_putchar(str[i], &ret_value); + i++; + } + free(str); + return (ret_value); +} diff --git a/libft/ft_put.c b/libft/ft_put.c new file mode 100644 index 0000000..f81ec8a --- /dev/null +++ b/libft/ft_put.c @@ -0,0 +1,82 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_put.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/16 12:13:14 by rparodi #+# #+# */ +/* Updated: 2024/03/06 11:25:24 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +void ft_putchar(char c, int *ret_value) +{ + write(1, &c, 1); + (*ret_value)++; +} + +void ft_putnbr(int nb, int *ret_value) +{ + if (nb < 0) + { + if (nb == INT_MIN) + { + write(1, "-2147483648", 11); + *ret_value += 11; + return ; + } + nb = -nb; + ft_putchar('-', ret_value); + } + if (nb >= 10) + { + ft_putnbr(nb / 10, ret_value); + nb = nb % 10; + } + if (nb < 10) + ft_putchar(nb + 48, ret_value); +} + +void ft_putnbr_base(unsigned long long nbr, char *base, int *ret_value, + char c) +{ + if (c == 'p') + { + if (nbr != 0) + ft_putstr("0x", ret_value); + if (nbr == 0) + { + ft_putstr("(nil)", ret_value); + return ; + } + c++; + } + if (c != 'p') + { + if (nbr >= 16) + ft_putnbr_base(nbr / 16, base, ret_value, c); + ft_putchar(base[nbr % 16], ret_value); + } +} + +void ft_putnbr_unsigned(unsigned int nb, int *ret_value) +{ + if (nb >= 10) + { + ft_putnbr_unsigned(nb / 10, ret_value); + nb = nb % 10; + } + if (nb < 10) + ft_putchar(nb + 48, ret_value); +} + +void ft_putstr(char *str, int *ret_value) +{ + if (!str) + *ret_value += write(1, "(null)", 6); + else + *ret_value += write(1, str, ft_strlen(str)); +} diff --git a/libft/ft_reverse_split.c b/libft/ft_reverse_split.c new file mode 100644 index 0000000..65ca393 --- /dev/null +++ b/libft/ft_reverse_split.c @@ -0,0 +1,114 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_reverse_split.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/02/22 11:18:33 by rparodi #+# #+# */ +/* Updated: 2024/03/10 18:28:07 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +size_t ft_count_line(char *path) +{ + char *str; + size_t count; + int fd; + + count = 0; + fd = open(path, O_RDONLY); + str = get_next_line(fd); + while (str != NULL) + { + free(str); + count++; + str = get_next_line(fd); + } + free(str); + close(fd); + return (count); +} + +char **ft_init_map(t_mlx *mlx, char *path) +{ + int check; + size_t total_size; + size_t j; + + j = 0; + check = 1; + total_size = ft_count_line(path); + if (mlx->map != NULL) + ft_free_maps(mlx->map, NULL); + mlx->map = (char **)malloc(sizeof(char *) * (total_size + 1)); + if (!mlx->map) + ft_exit(mlx, NULL, 0, "The allocation of the map crashed"); + while (check != 0 && mlx->map != NULL) + { + mlx->map[j] = get_next_line(mlx->fd_map); + if (mlx->map[j] == NULL) + check = 0; + j++; + } + return (mlx->map); +} + +size_t ft_strslen(char **strs) +{ + size_t counter; + size_t i; + size_t j; + + counter = 0; + i = 0; + j = 0; + while (strs[j] != NULL) + { + while (strs[j][i] != '\0') + { + counter++; + i++; + } + i = 0; + j++; + } + return (counter); +} + +char *ft_convert_strs_to_str(char *str, char **strs) +{ + size_t i; + size_t j; + size_t k; + + i = 0; + j = 0; + k = 0; + while (strs[j] != NULL) + { + while (strs[j][i] != '\0') + { + str[k] = strs[j][i]; + i++; + k++; + } + i = 0; + j++; + } + str[k] = '\0'; + return (str); +} + +char *ft_reverse_split(t_mlx *mlx) +{ + const size_t total_size = ft_strslen(mlx->map); + char *str; + + str = (char *)malloc(total_size + 1); + if (str == NULL) + ft_exit(mlx, NULL, 0, "The allocation of the string crashed"); + return (ft_convert_strs_to_str(str, mlx->map)); +} diff --git a/libft/ft_split.c b/libft/ft_split.c new file mode 100644 index 0000000..41fec9d --- /dev/null +++ b/libft/ft_split.c @@ -0,0 +1,93 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_split.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/09 13:56:02 by rparodi #+# #+# */ +/* Updated: 2024/03/06 11:26:19 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +static int count_words(const char *str, char sep) +{ + int i; + int count; + + i = 0; + count = 0; + while (str[i]) + { + while (str[i] == sep && str[i]) + i++; + if (str[i] != sep && str[i]) + { + while (str[i] != sep && str[i]) + i++; + count++; + } + } + return (count); +} + +static char *ft_strndup(const char *s, int j) +{ + int i; + char *str; + + i = 0; + str = (char *)malloc((j + 1)); + if (!str) + return (NULL); + while (s[i] && i < j) + { + str[i] = s[i]; + i++; + } + str[i] = '\0'; + return (str); +} + +static char **ext_w(char **words_array, const char *str, char sep, int size) +{ + int i; + int j; + + i = 0; + j = 0; + while (j < size) + { + while (str[i] == sep && str[i]) + i++; + str = str + i; + i = 0; + while (str[i] != sep && str[i]) + i++; + words_array[j++] = ft_strndup(str, i); + str = str + i; + i = 0; + } + words_array[j] = 0; + return (words_array); +} + +char **ft_split(char const *s, char c) +{ + int size; + char **words_array; + + size = count_words(s, c); + words_array = (char **)malloc(sizeof(char *) * (size + 1)); + if (!words_array) + return (NULL); + if (size == 0) + { + words_array[0] = NULL; + return (words_array); + } + words_array = ext_w(words_array, s, c, size); + return (words_array); +} diff --git a/libft/ft_strdup.c b/libft/ft_strdup.c new file mode 100644 index 0000000..cbefa6d --- /dev/null +++ b/libft/ft_strdup.c @@ -0,0 +1,45 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/07 16:53:59 by rparodi #+# #+# */ +/* Updated: 2024/03/06 11:26:19 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +char **ft_strsdup(char **s, t_mlx *mlx) +{ + const size_t len = ft_count_line(mlx->path); + size_t i; + char **to_return; + + i = 0; + to_return = (char **)malloc(sizeof(char *) * mlx->size_map); + if (!to_return) + return (NULL); + while (i < len) + { + to_return[i] = ft_strdup(s[i]); + i++; + } + to_return[i] = NULL; + return (to_return); +} + +char *ft_strdup(const char *s) +{ + size_t len; + char *to_return; + + len = ft_strlen(s) + 1; + to_return = (char *)malloc(sizeof(char) * len); + if (!to_return) + return (NULL); + ft_strlcpy(to_return, s, len); + return (to_return); +} diff --git a/libft/ft_strlcpy.c b/libft/ft_strlcpy.c new file mode 100644 index 0000000..bed1000 --- /dev/null +++ b/libft/ft_strlcpy.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/07 16:55:25 by rparodi #+# #+# */ +/* Updated: 2024/03/06 11:26:19 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +size_t ft_strlcpy(char *dst, const char *src, size_t size) +{ + size_t i; + + i = 0; + while (src[i] != '\0' && i + 1 < size) + { + dst[i] = src[i]; + i++; + } + if (size > 0) + { + dst[i] = '\0'; + i++; + } + return (ft_strlen(src)); +} diff --git a/libft/get_next_line.c b/libft/get_next_line.c new file mode 100644 index 0000000..931993b --- /dev/null +++ b/libft/get_next_line.c @@ -0,0 +1,78 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* get_next_line.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/18 17:12:02 by rparodi #+# #+# */ +/* Updated: 2024/03/06 11:26:19 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +char *ft_check(char *memory, int fd) +{ + char *buffer; + int bytescopy; + + bytescopy = 1; + buffer = (char *)malloc(sizeof(char) * (BUFFER_SIZE + 1)); + if (!buffer) + return (NULL); + while (ft_index_strchr(memory, '\n') <= 0 && bytescopy) + { + bytescopy = read(fd, buffer, BUFFER_SIZE); + if (bytescopy == -1) + return (ft_free(buffer)); + buffer[bytescopy] = '\0'; + memory = ft_strjoin(memory, buffer, 0, -1); + } + free(buffer); + return (memory); +} + +char *file_converted(int fd) +{ + size_t i; + int read_bits; + char *str; + char c; + + i = 0; + c = 1; + read_bits = 1; + str = (char *)malloc(sizeof(char) * BUFFER_SIZE); + if (!str) + return (NULL); + while (read_bits != 0 && i < BUFFER_SIZE) + { + read_bits = read(fd, &c, 1); + str[i] = c; + i++; + } + str[i] = '\0'; + return (str); +} + +char *ft_free(char *str) +{ + free(str); + return (NULL); +} + +char *get_next_line(int fd) +{ + static char *memory = NULL; + char *line; + + if (fd < 0 || BUFFER_SIZE <= 0) + return (NULL); + memory = ft_check(memory, fd); + if (!memory) + return (ft_free(memory)); + line = ft_get_line(memory); + memory = ft_get_next(memory); + return (line); +} diff --git a/libft/get_next_line_utils.c b/libft/get_next_line_utils.c new file mode 100644 index 0000000..74c0550 --- /dev/null +++ b/libft/get_next_line_utils.c @@ -0,0 +1,119 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* get_next_line_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/18 17:14:47 by rparodi #+# #+# */ +/* Updated: 2024/03/06 11:26:19 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +size_t ft_strlen(char const *str) +{ + size_t i; + + i = 0; + if (str) + { + while (str[i]) + i++; + } + return (i); +} + +char *ft_strjoin(char *s1, char *s2, int i, int j) +{ + char *temp; + + if (!s1) + { + s1 = (char *)malloc(1); + s1[i] = '\0'; + } + if (!s2 || !s1) + return (NULL); + temp = (char *)malloc((ft_strlen(s1) + ft_strlen(s2) + 1)); + if (!temp) + return (NULL); + while (s1[i]) + { + temp[i] = s1[i]; + i++; + } + while (s2[++j]) + temp[i + j] = s2[j]; + temp[i + j] = '\0'; + free(s1); + return (temp); +} + +char *ft_get_line(char *str) +{ + char *temp; + int i; + + i = 0; + if (!str[i]) + return (NULL); + while (str[i] && str[i] != '\n') + i++; + temp = (char *)malloc((i + 2)); + if (!temp) + return (NULL); + i = 0; + while (str[i] && str[i] != '\n') + { + temp[i] = str[i]; + i++; + } + if (str[i] == '\n') + { + temp[i] = str[i]; + i++; + } + temp[i] = '\0'; + return (temp); +} + +char *ft_get_next(char *str) +{ + char *temp; + int i; + int j; + + i = 0; + while (str[i] && str[i] != '\n') + i++; + if (!str[i]) + return (ft_free(str)); + temp = (char *)malloc((ft_strlen(str) - i)); + if (!temp) + return (NULL); + j = i + 1; + while (str[++i]) + temp[i - j] = str[i]; + temp[i - j] = '\0'; + free(str); + return (temp); +} + +int ft_index_strchr(const char *s, char c) +{ + int i; + + i = 0; + if (s) + { + while (s[i]) + { + if (s[i] == c) + return (i + 1); + i++; + } + } + return (0); +} diff --git a/maps/empty.ber b/maps/empty.ber new file mode 100644 index 0000000..21452db --- /dev/null +++ b/maps/empty.ber @@ -0,0 +1,3 @@ +1111111 +1CP00E1 +1111111 \ No newline at end of file diff --git a/maps/map-square.ber b/maps/map-square.ber new file mode 100644 index 0000000..c121c20 --- /dev/null +++ b/maps/map-square.ber @@ -0,0 +1,5 @@ +11111 +1E001 +100C1 +10PC1 +11111 \ No newline at end of file diff --git a/maps/map1.ber b/maps/map1.ber new file mode 100644 index 0000000..0f041e3 --- /dev/null +++ b/maps/map1.ber @@ -0,0 +1,3 @@ +11111 +1PCE1 +11111 diff --git a/maps/map2.ber b/maps/map2.ber new file mode 100644 index 0000000..66027fe --- /dev/null +++ b/maps/map2.ber @@ -0,0 +1,5 @@ +1111111111111 +100100C0000C1 +1C00011111001 +1P0011E000001 +1111111111111 diff --git a/maps/map3.ber b/maps/map3.ber new file mode 100644 index 0000000..1bb91f5 --- /dev/null +++ b/maps/map3.ber @@ -0,0 +1,6 @@ +1111111111111111111111111111111111 +1E0000000000000C00000C000000000001 +1010010100100000101001000000010101 +1010010010101010001001000000010101 +1P0000000C00C0000000000000000000C1 +1111111111111111111111111111111111 diff --git a/maps/map4.ber b/maps/map4.ber new file mode 100644 index 0000000..b49be7e --- /dev/null +++ b/maps/map4.ber @@ -0,0 +1,7 @@ +1111111111111111111 +10000000C0000001111 +1001011111000001111 +10010000C0000P01111 +1001000000000E01111 +10001111101100000C1 +1111111111111111111 diff --git a/maps/map5.ber b/maps/map5.ber new file mode 100644 index 0000000..6f4793a --- /dev/null +++ b/maps/map5.ber @@ -0,0 +1,7 @@ +1111111111111111111 +10010000C0000001111 +1001011111000001111 +10010000C0000P01111 +1001000000000E01111 +10001111101100000C1 +1111111111111111111 diff --git a/maps/maps_classic.ber b/maps/maps_classic.ber new file mode 100644 index 0000000..809a2f5 --- /dev/null +++ b/maps/maps_classic.ber @@ -0,0 +1,5 @@ +1111111111111 +1001000000001 +1000011111001 +1P0011E000001 +1111111111111 diff --git a/maps/maps_classic2.ber b/maps/maps_classic2.ber new file mode 100644 index 0000000..1bb91f5 --- /dev/null +++ b/maps/maps_classic2.ber @@ -0,0 +1,6 @@ +1111111111111111111111111111111111 +1E0000000000000C00000C000000000001 +1010010100100000101001000000010101 +1010010010101010001001000000010101 +1P0000000C00C0000000000000000000C1 +1111111111111111111111111111111111 diff --git a/sources/ft_check_map.c b/sources/ft_check_map.c new file mode 100644 index 0000000..c171f80 --- /dev/null +++ b/sources/ft_check_map.c @@ -0,0 +1,105 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_check_map.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/11 12:52:02 by rparodi #+# #+# */ +/* Updated: 2024/03/10 18:24:11 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +size_t what_is_it(char *str, size_t i, size_t line, t_mlx *mlx) +{ + if (str[i] == '\n') + { + if (line == 0) + line = i; + else if (str[i - 1] == '1' && (str[i + 1] == '1' || str[i + 1] == '\0')) + return (line); + else + ft_exit(mlx, str, 1, "The map is invalid (not a rectangle)"); + } + else if (str[i] == '1') + return (line); + else if (str[i] == '0') + return (line); + else if (str[i] == 'P') + return (line); + else if (str[i] == 'C') + return (line); + else if (str[i] == 'E') + return (line); + else + ft_exit(mlx, str, 1, "The map is invalid (unassigned char)"); + return (line); +} + +int check_border(char *str, t_mlx *mlx) +{ + size_t i; + + i = 0; + while (str[i] != '\n') + { + if (str[i] != '1') + ft_exit(mlx, str, 1, "The first line isn't good !"); + i++; + } + i = ft_strlen(str) - 2; + while (str[i] != '\n') + { + if (str[i] != '1') + ft_exit(mlx, str, 1, "The last line isn't good !"); + i--; + } + ft_parsing(str, mlx); + return (1); +} + +size_t ft_linelen(t_mlx *mlx) +{ + size_t line; + size_t i; + char *str; + size_t nb_coins; + size_t nb_exit; + + i = 0; + line = 0; + nb_coins = 0; + nb_exit = 0; + str = ft_reverse_split(mlx); + while (str[i] != '\0') + { + line = what_is_it(str, i, line, mlx); + if (str[i] == 'C') + nb_coins++; + if (str[i] == 'E') + nb_exit++; + i++; + } + if (nb_coins == 0 || nb_exit == 0) + ft_exit(mlx, str, 1, "The map isn't valid (No Coins or Exit)"); + check_border(str, mlx); + return (line); +} + +void check_args(int argc, char *argv[], t_mlx *mlx) +{ + mlx->fd_map = 0; + if (argc == 2) + { + mlx->fd_map = open(argv[1], O_RDONLY); + if (mlx->fd_map < 3) + ft_exit(mlx, NULL, 1, "File opening failed !"); + else + { + ft_init_map(mlx, argv[1]); + ft_linelen(mlx); + } + } +} diff --git a/sources/ft_exit.c b/sources/ft_exit.c new file mode 100644 index 0000000..1164d50 --- /dev/null +++ b/sources/ft_exit.c @@ -0,0 +1,65 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_exit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/18 18:07:39 by rparodi #+# #+# */ +/* Updated: 2024/03/10 17:53:42 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +void ft_free_maps(char **strs, char **copy) +{ + size_t i; + + i = 0; + while (strs[i] != NULL) + { + free(strs[i]); + i++; + } + free(strs); + if (copy != NULL) + { + i = 0; + while (copy[i] != NULL) + { + free(copy[i]); + i++; + } + free(copy); + } +} + +void ft_exit(t_mlx *mlx, void *p2, short int exit_status, char *leaving_msg) +{ + if (mlx != NULL) + { + if (mlx->fd_map > 0) + close(mlx->fd_map); + ft_free_image(mlx); + if (mlx->window) + mlx_destroy_window(mlx->init, mlx->window); + if (mlx->init) + mlx_destroy_display(mlx->init); + ft_free_maps(mlx->map, NULL); + free(mlx->init); + free(mlx); + } + free(p2); + if (exit_status == 1) + ft_printf("\n\nError:\n> %s\n", leaving_msg); + else if (exit_status == 0) + ft_printf("\n\n> %s\n", leaving_msg); + exit(exit_status); +} + +int ft_close(t_mlx *mlx) +{ + ft_exit(mlx, NULL, 0, "Your leaving? see you! (Reason: Red Cross)"); + return (42); +} diff --git a/sources/ft_init.c b/sources/ft_init.c new file mode 100644 index 0000000..fd54c29 --- /dev/null +++ b/sources/ft_init.c @@ -0,0 +1,102 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_init.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/19 13:25:35 by rparodi #+# #+# */ +/* Updated: 2024/03/17 00:16:49 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +char ft_init_image(t_mlx *mlx) +{ + mlx->store.wall = load_image(mlx, "./textures/wall.xpm"); + mlx->store.floor = load_image(mlx, "./textures/floor.xpm"); + mlx->store.coins = load_image(mlx, "./textures/coins.xpm"); + mlx->store.player = load_image(mlx, "./textures/steve.xpm"); + mlx->store.lock = load_image(mlx, "./textures/exit_close.xpm"); + mlx->store.open = load_image(mlx, "./textures/exit_open.xpm"); + if (mlx->store.wall.img_ptr == NULL || mlx->store.floor.img_ptr == NULL \ + || mlx->store.coins.img_ptr == NULL || mlx->store.player.img_ptr == NULL \ + || mlx->store.lock.img_ptr == NULL || mlx->store.open.img_ptr == NULL) + return (1); + return (0); +} + +t_mlx *ft_init_mlx(t_mlx *mlx, int argc, char *argv[]) +{ + mlx->init = mlx_init(); + if (!mlx->init) + ft_exit(mlx, NULL, 1, "The allocation of mlx has crashed"); + ft_init_map(mlx, argv[1]); + check_args(argc, argv, mlx); + map_size(mlx); + mlx->window = mlx_new_window(mlx->init, mlx->map_l, mlx->map_h, \ + "so_long by rparodi"); + if (!mlx->window) + ft_exit(mlx, NULL, 1, "The allocation of the window has crashed"); + if (ft_init_image(mlx)) + ft_exit(mlx, NULL, 1, "The allocation of the window has crashed"); + display_map(mlx); + mlx_hook(mlx->window, 2, 1L << 0, key_hook, mlx); + mlx_hook(mlx->window, 17, 1L << 17, ft_close, mlx); + mlx_loop(mlx->init); + return (mlx); +} + +void display_map(t_mlx *mlx) +{ + t_image image; + size_t i; + size_t j; + + i = 0; + j = 0; + while (j < mlx->map_h && mlx->map[j]) + { + while (i + 1 < mlx->map_l && mlx->map[j][i] != '\0'\ + && mlx->map[j][i] != '\n') + { + image = ft_whitch_case(mlx->map[j][i], mlx); + mlx_put_image_to_window(mlx->init, mlx->window, image.img_ptr, \ + i * image.w, j * image.h); + i++; + } + i = 0; + j++; + } +} + +t_image new_img(int w, int h, t_mlx *mlx) +{ + t_image image; + + image.img_ptr = mlx_new_image(mlx->init, w, h); + image.addr = mlx_get_data_addr(image.img_ptr, &(image.bpp), + &(image.line_len), &(image.endian)); + image.w = w; + image.h = h; + return (image); +} + +t_image load_image(t_mlx *mlx, char *path) +{ + t_image img; + int width; + int height; + + width = LONGUEUR / mlx->map_l; + height = HAUTEUR / mlx->map_h; + img.img_ptr = mlx_xpm_file_to_image(mlx->init, path, &width, &height); + if (img.img_ptr == NULL) + ft_exit(mlx, NULL, 1, "The allocation of the image has crashed"); + img.addr = mlx_get_data_addr(img.img_ptr, &(img.bpp), &(img.line_len), + &(img.endian)); + img.w = width; + img.h = height; + return (img); +} diff --git a/sources/ft_map.c b/sources/ft_map.c new file mode 100644 index 0000000..9e736c5 --- /dev/null +++ b/sources/ft_map.c @@ -0,0 +1,70 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_map.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/21 22:51:53 by rparodi #+# #+# */ +/* Updated: 2024/03/10 18:24:45 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +void ft_free_image(t_mlx *mlx) +{ + if (mlx->store.wall.img_ptr) + mlx_destroy_image(mlx->init, mlx->store.wall.img_ptr); + if (mlx->store.floor.img_ptr) + mlx_destroy_image(mlx->init, mlx->store.floor.img_ptr); + if (mlx->store.coins.img_ptr) + mlx_destroy_image(mlx->init, mlx->store.coins.img_ptr); + if (mlx->store.player.img_ptr) + mlx_destroy_image(mlx->init, mlx->store.player.img_ptr); + if (mlx->store.lock.img_ptr) + mlx_destroy_image(mlx->init, mlx->store.lock.img_ptr); + if (mlx->store.open.img_ptr) + mlx_destroy_image(mlx->init, mlx->store.open.img_ptr); +} + +void map_size(t_mlx *mlx) +{ + size_t i; + size_t prev_i; + size_t j; + + i = 0; + j = 0; + prev_i = 0; + while (mlx->map[j] != NULL) + { + while (mlx->map[j][i] != '\0' ) + i++; + if (mlx->map[j][i - 1] == '\n') + i--; + if (i != prev_i && prev_i != 0) + ft_exit(mlx, NULL, 1, "The map is not a rectangle"); + if (j == 0) + prev_i = i; + j++; + } + mlx->map_h = j * 32; + mlx->map_l = i * 32; +} + +t_image ft_whitch_case(char c, t_mlx *mlx) +{ + if (c == '1') + return (mlx->store.wall); + else if (c == '0') + return (mlx->store.floor); + else if (c == 'C') + return (mlx->store.coins); + else if (c == 'P') + return (mlx->store.player); + else if (c == 'E') + return (mlx->store.lock); + else + return (mlx->store.open); +} diff --git a/sources/ft_move.c b/sources/ft_move.c new file mode 100644 index 0000000..573fe56 --- /dev/null +++ b/sources/ft_move.c @@ -0,0 +1,86 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_move.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/02 15:19:03 by rparodi #+# #+# */ +/* Updated: 2024/03/07 11:23:21 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +void ft_move_up(int x, int y, t_mlx *mlx, unsigned int *count) +{ + int coins; + + coins = count_coins(mlx); + if (y > 0 && mlx->map[y - 1][x] != '1' && mlx->map[y - 1][x] != 'E') + { + ft_printf("You have use %d moves\r", ++(*count)); + if (mlx->map[y - 1][x] != 'E' && mlx->map[y - 1][x] != 'F') + { + mlx->map[y][x] = '0'; + mlx->map[y - 1][x] = 'P'; + } + else if (mlx->map[y - 1][x] == 'F' && coins == 0) + ft_exit(mlx, NULL, 0, "You have finish the game !"); + } +} + +void ft_move_down(int x, int y, t_mlx *mlx, unsigned int *count) +{ + int coins; + + coins = count_coins(mlx); + if (mlx->map[y + 1] && mlx->map[y + 1][x] != '1'\ + && mlx->map[y + 1][x] != 'E') + { + ft_printf("You have use %d moves\r", ++(*count)); + if (mlx->map[y + 1][x] != 'E' && mlx->map[y + 1][x] != 'F') + { + mlx->map[y][x] = '0'; + mlx->map[y + 1][x] = 'P'; + } + else if (mlx->map[y + 1][x] == 'F' && coins == 0) + ft_exit(mlx, NULL, 0, "You have finish the game !"); + } +} + +void ft_move_left(int x, int y, t_mlx *mlx, unsigned int *count) +{ + int coins; + + coins = count_coins(mlx); + if (x > 0 && mlx->map[y][x - 1] != '1' && mlx->map[y][x - 1] != 'E') + { + ft_printf("You have use %d moves\r", ++(*count)); + if (mlx->map[y][x - 1] != 'E' && mlx->map[y][x - 1] != 'F') + { + mlx->map[y][x] = '0'; + mlx->map[y][x - 1] = 'P'; + } + else if (mlx->map[y][x - 1] == 'F' && coins == 0) + ft_exit(mlx, NULL, 0, "You have finish the game !"); + } +} + +void ft_move_right(int x, int y, t_mlx *mlx, unsigned int *count) +{ + int coins; + + coins = count_coins(mlx); + if (x > 0 && mlx->map[y][x + 1] != '1' && mlx->map[y][x + 1] != 'E') + { + ft_printf("You have use %d moves\r", ++(*count)); + if (mlx->map[y][x + 1] != 'E' && mlx->map[y][x + 1] != 'F') + { + mlx->map[y][x] = '0'; + mlx->map[y][x + 1] = 'P'; + } + else if (mlx->map[y][x + 1] == 'F' && coins == 0) + ft_exit(mlx, NULL, 0, "You have finish the game !"); + } +} diff --git a/sources/ft_parse_map.c b/sources/ft_parse_map.c new file mode 100644 index 0000000..89ebe89 --- /dev/null +++ b/sources/ft_parse_map.c @@ -0,0 +1,118 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_parse_map.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/17 17:27:10 by rparodi #+# #+# */ +/* Updated: 2024/03/10 18:23:31 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +void flood_fill(char **map, int x, int y, const char *old_value) +{ + if (x < 0 || y < 0 || x >= (int)(sizeof(map) / ft_strlen(map[0])) + || y >= (int)(ft_strlen(map[0]))) + { + if (ft_index_strchr(old_value, map[x][y]) == 0) + return ; + map[x][y] = '.'; + flood_fill(map, x + 1, y, old_value); + flood_fill(map, x - 1, y, old_value); + flood_fill(map, x, y + 1, old_value); + flood_fill(map, x, y - 1, old_value); + } +} + +void ft_access(char **map, t_mlx *mlx, size_t i, size_t j) +{ + size_t k; + const char old_value[4] = {'P', 'C', 'E', '0'}; + + k = 0; + flood_fill(map, j, i, old_value); + while (map[k] != NULL) + { + if (ft_index_strchr(map[k], 'C') != 0 || \ + ft_index_strchr(map[k], 'E') != 0) + { + ft_free_maps(map, NULL); + ft_exit(mlx, NULL, 1, "The map is not finishable !"); + } + k++; + } +} + +void ft_check_finishable(char **map, char **copy, t_mlx *mlx) +{ + size_t j; + size_t i; + + j = 1; + i = 0; + while (map[j] && map[j][0] != '\0') + { + while (map[j][i] != '\0') + { + if (map[j][i] == 'P') + break ; + i++; + } + if (map[j][i] == 'P') + break ; + i = 0; + j++; + } + if (map[j] && map[j][i] == 'P') + ft_access(copy, mlx, i, j); + else + { + ft_free_maps(copy, NULL); + ft_exit(mlx, NULL, 1, "No Spawn found"); + } +} + +char ft_check_minimal(char *str, t_mlx *mlx) +{ + size_t i; + size_t nb_exit; + size_t nb_spawn; + + i = 0; + nb_exit = 0; + nb_spawn = 0; + while (str[i] != '\0') + { + if (str[i] == 'E') + { + if (nb_exit != 0) + ft_exit(mlx, str, 1, "Too many exit are detected !"); + nb_exit++; + } + else if (str[i] == 'P') + { + if (nb_spawn != 0) + ft_exit(mlx, str, 1, "Too many spawn are detected !"); + nb_spawn++; + } + i++; + } + return (1); +} + +void ft_parsing(char *str, t_mlx *mlx) +{ + char **copy; + + ft_check_minimal(str, mlx); + mlx->size_map = ft_strlen(str); + copy = ft_strsdup(mlx->map, mlx); + free(str); + if (copy == NULL) + ft_exit(mlx, NULL, 1, "The allocation of the map has crahsed !"); + ft_check_finishable(mlx->map, copy, mlx); + ft_free_maps(copy, NULL); +} diff --git a/sources/ft_value.c b/sources/ft_value.c new file mode 100644 index 0000000..990873d --- /dev/null +++ b/sources/ft_value.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_value.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/02/17 15:16:20 by rparodi #+# #+# */ +/* Updated: 2024/03/08 12:34:08 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +void ft_init_value_image(t_image *img) +{ + img->img_ptr = NULL; + img->addr = NULL; + img->h = 0; + img->w = 0; + img->bpp = 0; + img->endian = 0; + img->line_len = 0; +} + +void ft_init_value_mlx(t_mlx *mlx) +{ + mlx->init = NULL; + mlx->window = NULL; + mlx->w_h = 0; + mlx->w_l = 0; + mlx->fd_map = -1; + mlx->size_map = 0; + mlx->map = NULL; + mlx->map_h = 0; + mlx->map_l = 0; + mlx->img = NULL; + mlx->count = 0; +} diff --git a/sources/main.c b/sources/main.c new file mode 100644 index 0000000..2203e37 --- /dev/null +++ b/sources/main.c @@ -0,0 +1,129 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/10 11:13:09 by rparodi #+# #+# */ +/* Updated: 2024/03/10 17:50:02 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" +#include + +unsigned int count_coins(t_mlx *mlx) +{ + unsigned int i; + unsigned int j; + unsigned int coins; + + i = 0; + j = 0; + coins = 0; + while (mlx->map[j]) + { + while (mlx->map[j][i] != '\0') + { + if (mlx->map[j][i] == 'C') + coins++; + i++; + } + i = 0; + j++; + } + return (coins); +} + +void ft_check_end(t_mlx *mlx, unsigned int coins) +{ + int x; + int y; + + x = 0; + y = 0; + while (mlx->map[y] && coins == 0) + { + x = 0; + while (mlx->map[y][x]) + { + if (mlx->map[y][x] == 'E' || mlx->map[y][x] == 'F') + break ; + x++; + } + if (mlx->map[y][x] == 'E' || mlx->map[y][x] == 'F') + break ; + y++; + } + if (mlx->map[y][x] == 'E' && coins == 0) + mlx->map[y][x] = 'F'; +} + +void ft_check_pos(t_mlx *mlx, int *y, int *x) +{ + while (mlx->map[*y]) + { + *x = 0; + while (mlx->map[*y][*x]) + { + if (mlx->map[*y][*x] == 'P') + break ; + (*x)++; + } + if (mlx->map[*y][*x] == 'P') + break ; + (*y)++; + } +} + +int key_hook(int keycode, t_mlx *mlx) +{ + unsigned int coins; + int x; + int y; + + x = 0; + y = 0; + if (keycode == 53 || keycode == 65307) + ft_exit(mlx, NULL, 0, "Your leaving? see you! (Reason: Esc)"); + ft_check_pos(mlx, &y, &x); + coins = count_coins(mlx); + if (keycode == 126 || keycode == 65362 || keycode == 119 || keycode == 122) + ft_move_up(x, y, mlx, &mlx->count); + else if (keycode == 125 || keycode == 65364 || keycode == 115) + ft_move_down(x, y, mlx, &mlx->count); + else if (keycode == 65361 || keycode == 97 || keycode == 113) + ft_move_left(x, y, mlx, &mlx->count); + else if (keycode == 124 || keycode == 65363 || keycode == 100) + ft_move_right(x, y, mlx, &mlx->count); + ft_check_end(mlx, coins); + display_map(mlx); + return (0); +} + +int main(int argc, char *argv[]) +{ + t_mlx *mlx; + int temp; + + if (argc > 2) + ft_exit(NULL, NULL, 1, "You have to give a single maps"); + if (argc < 2) + ft_exit(NULL, NULL, 1, "You have to give a maps to see my project !"); + temp = open(argv[1], O_RDONLY); + if (temp < 3) + ft_exit(NULL, NULL, 1, "The file doesn't exist"); + close(temp); + mlx = (t_mlx *)malloc(sizeof(t_mlx)); + bzero(mlx, sizeof(t_mlx)); + if (argc == 2) + mlx->path = argv[1]; + else + ft_exit(mlx, NULL, 1, "You have to give a map to see my project"); + ft_init_value_mlx(&(*mlx)); + if (!mlx) + ft_exit(mlx, NULL, 1, "The allocation of mlx has crashed"); + mlx = ft_init_mlx(mlx, argc, argv); + return (0); +} diff --git a/textures/coins.xpm b/textures/coins.xpm new file mode 100644 index 0000000..0eaf6c6 --- /dev/null +++ b/textures/coins.xpm @@ -0,0 +1,52 @@ +/* XPM */ +static char * coins_xpm[] = { +"32 32 17 1", +" c #7F7F7F", +". c #747474", +"+ c #8F8F8F", +"@ c #B0B0B0", +"# c #A8A8A8", +"$ c #A3A3A3", +"% c #9D9D9D", +"& c #11727A", +"* c #D5FFF6", +"= c #FFFFFF", +"- c #A1FBE8", +"; c #4AEDD9", +"> c #145E53", +", c #2CE0D8", +"' c #20C5B5", +") c #1AAAA7", +"! c #1C919A", +" .. . ..++. +++ . ++ .. ++++ ", +".@@@#@####$$$###$$$%%$$########+", +".#$$$$#$$$###$$#@@#@@#%%$%%$#$$ ", +".###$###$$$#$$##$#$$###$%%$#$$#.", +".#$$%%%%$$$$$%%%%%$$$$$######$$+", +" @#$$%%$%%$#&&&&&&&&$###$$#####+", +"+$$$##$$$##&*====*=*&##$$#$%%$$+", +" #@@@@@@##&=*---;;;-*&@@@##$$##+", +"+$$$#@@$%&=*=-;;;;-*-->##@@$$$#.", +"+$#####$&=--=;;;---*-;,>##$$### ", +" @@@@#$&*-;-=;----;*-;;,>%$%%$@.", +".#@@###&=;;;=----;;*;,;;>$$$$$$.", +".$$#$#&*-;;;=*-;;;-*;,,;,>##### ", +"+$$$$$&==*;;-==*=**,;;'))>@@@$$.", +"+$$$%&*;-==-=-;;;--*'))'',>$###.", +"+##$$&=;;--=-;,;----)'))',>#### ", +"+#$$#&=;--;=;,;----;)'))',>$$$$ ", +"+@@@@&=;--;=;;----;;)'')),>#$$# ", +" ##@@&*--;;*;----;,;!''));>@@##+", +".#@@@&=--;-*----;,;'!)''),>@$$$+", +".%$##&*;-**,';-;,;'!)!!)';>$$%$+", +" ###$>***;;;))))!!!!'''!!!>@###+", +" ##$$#>-;,;;)''''')!'))';>#$$#@+", +"+#####>;;;,')''''''!))'';>##$$$+", +"+#$$#$$>,;;)')))))')!''->%%$%%$ ", +" ##$%%$#>,')'')))))'!'->%$$$$%%+", +" @@@@$#$$>,)'''''''');>#$$##$@@+", +".@@###$$$#>',;;-;---'>$$$##$$$# ", +".#$#$$##@@@>>>>>>>>>>###@@@@@@@.", +" $%%$#$$#@@###$$$#########@#@@@.", +" ##$$$###$#$$%%$#@@@@@#$#$$$$$# ", +".. ++++ .. ++++++ ..+ .. . + "}; diff --git a/textures/exit_close.xpm b/textures/exit_close.xpm new file mode 100644 index 0000000..c93af15 --- /dev/null +++ b/textures/exit_close.xpm @@ -0,0 +1,45 @@ +/* XPM */ +static char * exit_close_xpm[] = { +"32 32 10 1", +" c #4A3C20", +". c #625029", +"+ c #8B7141", +"@ c #9C794A", +"# c #735D31", +"$ c #A3A3A3", +"% c #A8A8A8", +"& c #B38C51", +"* c #B0B0B0", +"= c #9D9D9D", +" . .. . .. ", +" +@@@@@+++@@@@@@++++@@@@@@+++@+.", +".++++@@@@++++@+@@@@+++@++@@@@++.", +".@@+@@+++@@+@@@+++@@@@@@@+++@@@.", +".@+++@@@++@@@+++@@@+@+++@@+@+++ ", +" #++# ....#.#++##+# ..##..##+#. ", +".+@@+.$$$%%%&@@+@++.%%%$$%&@++@.", +".@@+@.**%%**&+@+@+@.%%***%@++@+ ", +" +@+@#*$==$$@@+@@+@.***%%*&+@@+.", +" @++@#%$$$%%&@+@+@+#%***%%&@+@+.", +".@+@+.$$%%%%&@+@+@+.$$%$==&@+@@.", +".@+@+.%%%%%$&@@++@+.=$===$&@+@+.", +" .#+##@&&&@&@#+++###&&@@&&@++#. ", +".@@@++++@++@@@@@+@+++++@@@+++@+.", +".++@@+@@@@@++++@@@@+@@+++@@@@@@.", +" @+++@++++@@@@++++@@@@@@@@++++@.", +".@@@@@@@@+++@@@@@@@@++@@+@@+@@+.", +".+@+++@+++@@@+@@++++@@@++++++@@ ", +".+++@@+@@@+++++@@@@++++@@@@@@++.", +" #+## ..#...##++#+# ..##..#+##. ", +".@+@@.%%$$$=&@@+@+@.$%%%$$@@+@+.", +" @+@+.$%%$%%@+@+@+@#%%****&@+@+ ", +".++@+.%%%%**@++@@++.%%%%**@+@++ ", +".@++@#%%%***&@+@+@+#%$$$$%&@@+@.", +".+@+@#$$%%*%&@+@+@+.%%$===&@@+@.", +".+@+@.$%****&@+@+@@.$$%$=$&@+@@ ", +" .#++#&&@&&&@+##++##&&&&@&@+#+# ", +".+++@@@@++@++++@@+++@@@++@++++@.", +" @@++++@@@@@@+@@+@@@++@@@@@+@@@.", +".++@@@@++++@@@++++@+@@@@+@+++@@.", +".@@@@+++@+@@++@@@++@@+++@@@@+++ ", +" . .. . .. "}; diff --git a/textures/exit_open.xpm b/textures/exit_open.xpm new file mode 100644 index 0000000..d90cd5c --- /dev/null +++ b/textures/exit_open.xpm @@ -0,0 +1,48 @@ +/* XPM */ +static char * exit_open_xpm[] = { +"32 32 13 1", +" c #7F7F7F", +". c #747474", +"+ c #7E6237", +"@ c #967441", +"# c #67502C", +"$ c #513D24", +"% c #8F8F8F", +"& c #B0B0B0", +"* c #A8A8A8", +"= c #A3A3A3", +"- c #9D9D9D", +"; c #B58D50", +"> c #3A2F1E", +" .. +@#$.%%. %%% . %% #@#$%%% ", +".&&&+@#$**===***===--==*#@#$***%", +".*;;;;;+@;;;;;;;;;;;;;;;;;;+;;= ", +".*@@;@;#+;;@@@@;;;@@+@;+@+@#@@*.", +".*@+@;;#+@+@;;;;@@;;;@@+@@@#@+=%", +" &#$+##$$#$$$###$$$#$##$+##$$$*%", +"%===#$$>=******&&&&&***=#$$>-==%", +" *&&++#$**&&*==**&&***&&++#$=**%", +"%===+@#$--==**==**&&&&&*+@#$==*.", +"%=**#@#$==**==***&&**&&&#@#$*** ", +" &;;;;;+@;;;;;;;;;;;;;;@;;;+;;&.", +".*@+;@@#+@@;;;@+@@;;;@@+@++#@@=.", +".=@+;;@#+@;;@@@;;;;@+@@+@@+#+@* ", +"%=$$+##$$###$#$$$$$#$$#$+##$$#=.", +"%===#$$$-=--=**===*==**=#$$>***.", +"%**=++#$========****====++#$*** ", +"%*==+@#$=*==*&&&&&&&*=**+@#$=== ", +"%&&&+@#$&&&***&&&**====*+@#$==* ", +" *;;;;;+@;;;;;;;;;;;;;;@;;;+;;*%", +".*;;;+@+@@@@;;;@@+@;;@@+;@@#@+=%", +".-@+@@@#+@;;@+@@;;@@;;@+@;@#@@=%", +" *$$+##$$#$###$$##$$$$#$+##$$$*%", +" **=#$$>**&&&&&*&&******#$$>=*&%", +"%***++#$*&&&&*****==*===+@#$===%", +"%*==+@#$**&***==--=***=-+@#$--= ", +" **=+@#$&&&&***==***==*=#@#$=--%", +" &;;;;;+;;;;;;;;;;;;;;;@;;;+;;&%", +".&@+@+@#+@@+@;;;@@@;;;@+;@@#@@* ", +".*@+@@;#+;;;@@@@@;;;@+@+@;@#+@&.", +" =#$+##$$###$$$$#$#$$$#$+##$$#&.", +" **=#$$>*=*==--=*&&&&&*=#$$>==* ", +".. %++#$.. %%%%%% ..% .+@#$% "}; diff --git a/textures/floor.xpm b/textures/floor.xpm new file mode 100644 index 0000000..ca42b14 --- /dev/null +++ b/textures/floor.xpm @@ -0,0 +1,45 @@ +/* XPM */ +static char *b2ffa1f3349541dfd85c9d78164cd8f5fwrUjFoX83Qd2gcH[] = { +/* columns rows colors chars-per-pixel */ +"32 32 7 1", +" c #747474", +". c gray50", +"X c gray56", +"o c #9D9D9D", +"O c gray64", +"+ c gray66", +"@ c gray69", +/* pixels */ +". .. . XX .XXX. ...XX. .XXXX.", +" @@@+@++++OOO+++OOOooOO++++++++X", +" +OOOO+OOO+++OO+@@+@@+ooOooO+OO.", +" +++O+++OOO+OO++O+OO+++OooO+OO+ ", +" +OOooooOOOOOoooooOOOOO++++++OOX", +".@+OOooOooO++OoOOOO+O+++OO+++++X", +"XOOO++OOO++++++@@@@@+++OO+OooOOX", +".+@@@@@@++@@+OO++@@+++@@@++OO++X", +"XOOO+@@OooOO++OO++@@@@@++@@OOO+ ", +"XO+++++OOO++OO+++@@++@@@++OO+++.", +".@@@@+OO++++++OO++OOOO+OooOooO@ ", +" +@@+++++++OOOO++OOooOoooOOOOOO ", +" OO+O+@@@@@+O+@@@@@OOOOO+++++++.", +"XOOOOOOO@@+OOO+@+OOOooO+++@@@OO ", +"XOOOoooooOooO++OOO+OO++OOOOO+++ ", +"X++OOoOoOOOOOOOO++++OOOOO++++++.", +"X+OO+++OO+OO+@@@@@@@+O++OO+OOOO.", +"X@@@@@++@@@+++@@@++OOOO+++++OO+.", +".++@@++OO+O+@@++@@++O+@@@++@@++X", +" +@@@@+++++OO+@@++++OOO++@@@OOOX", +" oO+++++OOOoooOoOO+OO+++OO+OOoOX", +".+++OOO++O++OooOO+++++@@@@@@+++X", +".++OO+++++@@@@@+@@++++++@@+OO+@X", +"X++++++++@@@@+++++OO+OOOO+++OOOX", +"X+OO+OOO++@+++OOooO+++OooooOooO.", +".++OooO+@@@@+++OO+++OO+OoOOOOooX", +".@@@@O+OOO++OO++OOO@@+++OO++O@@X", +" @@+++OOO+++++OOOO+++OOOO++OOO+.", +" +O+OO++@@@@@OOO++OO++++@@@@@@@ ", +".OooO+OO+@@+++OOO+++++++++@+@@@ ", +".++OOO+++O+OOooO+@@@@@+O+OOOOO+.", +" .XXXX. .XXXXXX. X.. . .X..." +}; diff --git a/textures/steve.xpm b/textures/steve.xpm new file mode 100644 index 0000000..63298b0 --- /dev/null +++ b/textures/steve.xpm @@ -0,0 +1,208 @@ +/* XPM */ +static char * steve_xpm[] = { +"32 32 173 2", +" c #5B3000", +". c #6C400C", +"+ c #81541E", +"@ c #936932", +"# c #956632", +"$ c #986733", +"% c #825423", +"& c #6D4010", +"* c #5A2E00", +"= c #A67C45", +"- c #AA7A46", +"; c #6C3F0F", +"> c #AA7C49", +", c #D0B476", +"' c #D3B779", +") c #BD8D56", +"! c #C18F58", +"~ c #FEEFB6", +"{ c #FEF5BC", +"] c #B99159", +"^ c #95662F", +"/ c #7F561F", +"( c #A47E4A", +"_ c #A5824C", +": c #BA9A69", +"< c #BE8F5D", +"[ c #9D824D", +"} c #FDFDC2", +"| c #8D6A33", +"1 c #F4E8A8", +"2 c #FDEDB9", +"3 c #FEFECC", +"4 c #FFF2B4", +"5 c #D8BE87", +"6 c #AC874F", +"7 c #FDF7CA", +"8 c #FEFFD2", +"9 c #FEFFBC", +"0 c #E7D79A", +"a c #ECD59A", +"b c #F0D399", +"c c #C09E65", +"d c #926B2F", +"e c #EAD495", +"f c #9D7A4A", +"g c #9F7E52", +"h c #968755", +"i c #E4FDBA", +"j c #E6FFC3", +"k c #DEF7CA", +"l c #F4FFCC", +"m c #E4D4A2", +"n c #9F793D", +"o c #A18145", +"p c #A98C5B", +"q c #F6E3C3", +"r c #FFFAE3", +"s c #F3FFE3", +"t c #79C46E", +"u c #36A134", +"v c #2BA42A", +"w c #C1F09E", +"x c #F4FDC6", +"y c #339C2C", +"z c #F5FFDD", +"A c #7F7F7F", +"B c #A68E5D", +"C c #F2E3CC", +"D c #FDFCF3", +"E c #EAFFEA", +"F c #6ACE71", +"G c #25A72A", +"H c #18A924", +"I c #B9F8A8", +"J c #EFFFCF", +"K c #BBF4A3", +"L c #17B127", +"M c #69C96C", +"N c #EFFFE5", +"O c #FFF9ED", +"P c #FFF7EC", +"Q c #8F8F8F", +"R c #747474", +"S c #D4C897", +"T c #DBCBB5", +"U c #F2E6DC", +"V c #EDE5DA", +"W c #DBFCD8", +"X c #63BC62", +"Y c #1B951C", +"Z c #088E09", +"` c #17820D", +" . c #BFEDA2", +".. c #C5EA9D", +"+. c #21931B", +"@. c #0B9712", +"#. c #129312", +"$. c #D2C08D", +"%. c #D4C180", +"&. c #D5C07E", +"*. c #E2C181", +"=. c #E2D4BC", +"-. c #F5ECE3", +";. c #ECEBE1", +">. c #E1FBD8", +",. c #198C14", +"'. c #C8E7A9", +"). c #63B55C", +"!. c #CAB787", +"~. c #2B8F1E", +"{. c #D5CBB5", +"]. c #E3DBD2", +"^. c #DBDCD3", +"/. c #D5E9CD", +"(. c #8FCC8A", +"_. c #4FAA4B", +":. c #65AB58", +"<. c #58B053", +"[. c #81BE7A", +"}. c #332D19", +"|. c #333019", +"1. c #353126", +"2. c #292627", +"3. c #22241E", +"4. c #34432C", +"5. c #2D4324", +"6. c #3B4533", +"7. c #474534", +"8. c #4B3F33", +"9. c #315331", +"0. c #373837", +"a. c #323435", +"b. c #2C2B2B", +"c. c #322A27", +"d. c #342C32", +"e. c #343837", +"f. c #2E3133", +"g. c #1D1D1D", +"h. c #211E21", +"i. c #252225", +"j. c #2C2C30", +"k. c #1B213F", +"l. c #181E3E", +"m. c #1D2244", +"n. c #212649", +"o. c #212749", +"p. c #31395A", +"q. c #2E3859", +"r. c #2C3456", +"s. c #1F2749", +"t. c #061D70", +"u. c #172E84", +"v. c #274097", +"w. c #354FA8", +"x. c #3853AC", +"y. c #2A429B", +"z. c #162E88", +"A. c #091F7A", +"B. c #001B8D", +"C. c #0E2CA3", +"D. c #1D3FB5", +"E. c #1B40B4", +"F. c #3154CC", +"G. c #2F52CC", +"H. c #2041B9", +"I. c #001A94", +"J. c #223FBD", +"K. c #0E2CA9", +"L. c #001C9A", +"M. c #1D3FB9", +"N. c #1A40B9", +"O. c #3155D2", +"P. c #2F54D0", +" . . . . + + + + @ @ @ # # # # $ + + + % & & & & * * * * ", +" . . . . + + + + @ @ @ # # # # # + + + % & & & & * * * * ", +" . . . . + + + + @ @ @ # # # # # + + + % & & & & * * * * ", +" . . . . + + + + @ @ @ # # # # # + + + % & & & & * * * * ", +". . . . + + + + @ @ @ @ = = = - - - - - $ $ $ $ % % % % ; ; ; ; ", +". . . . + + + + @ @ @ @ = = = - - - - - $ $ $ $ % % % % ; ; ; ; ", +". . . . + + + + @ @ @ @ = = = - - - - - $ $ $ $ % % % % ; ; ; ; ", +". . . . + + + + @ @ @ @ = = = = - - - - $ $ $ $ % % % % ; . . . ", +"+ + + + @ @ @ # - - > = , ' ' ' ) ! ! ! - - - - # # # # + + + + ", +"+ + + + @ @ @ # - > > > ~ { { { ] ) ) ) - - - - ^ ^ ^ ^ + + + + ", +"+ + / / @ @ @ @ > > ( _ ~ { { { : < < < > > > > @ @ @ @ + + + + ", +"+ / / / @ @ @ @ ( [ [ [ { } } } : : : : _ _ _ _ | | | @ + + + + ", +"@ @ @ @ = = > _ 1 { 2 2 3 3 3 3 3 3 3 } ~ 4 4 1 5 5 5 6 @ @ # # ", +"@ @ @ @ = = > _ 2 3 7 } 3 3 3 3 8 8 3 3 9 9 9 1 0 a b c @ @ # $ ", +"d d @ @ = = > _ { 3 3 3 3 3 3 3 8 8 8 3 } 9 9 1 0 0 e : @ @ # $ ", +"d d @ | f g g h i j k j l 3 3 3 8 8 8 l i i i i m m m : | | @ # ", +"= n o p q r r s t u v u w l 3 x 3 x l w y v y t z r r q 0 e e A ", +"= n o B C D D E F G H v I J x } } } l K G L H M N O O C m 0 e A ", +"o n o B C D D E F G H v I l x } } } x K G L H M s O P C m e e Q ", +"o n o B C D D E F G H v K l } } } } } w v L G M s O P C m e e Q ", +"R , ' S T U V W X Y Z ` .x } } } } } ..+.@.#.X k U V T $.%.&.Q ", +"A *.' $.=.-.;.>.X Y Z ,.'.x } } } } } ..` Z #.).>.-.U =.$.%.&.Q ", +"A *.' !.=.;.;.W ).+.#.~...x } } } } } ..` #.,.).k U V T $.%.&.Q ", +"Q !.!.!.{.].^./.(._._.:.'.7 7 3 3 3 3 '.<.<._.[./.].].{.S $.5 Q ", +"}.|.|.|.1.2.3.3.4.5.5.5.6.7.8.7.7.7.7.4.9.9.9.9.6.0.a.1.1.}.}.}.", +"3.3.3.3.3.3.3.2.b.b.2.c.d.d.d.a.e.e.a.a.a.a.e.0.f.f.b.b.b.2.2.2.", +"g.g.g.g.h.h.h.i.i.i.i.i.d.d.d.d.a.a.a.a.f.f.a.f.j.j.j.b.b.2.2.2.", +"k.k.k.l.l.l.l.l.m.m.n.n.o.o.o.o.p.p.q.q.r.r.r.r.o.s.o.o.m.m.m.m.", +"t.t.t.t.u.u.u.u.v.v.v.v.w.w.w.w.w.x.x.x.y.y.y.y.z.z.z.z.A.A.A.A.", +"B.B.B.B.C.C.C.C.D.D.E.E.F.F.F.F.F.F.G.G.H.H.H.H.C.C.C.C.I.I.I.I.", +"I.I.I.I.C.C.C.C.D.D.D.E.F.F.G.G.F.F.G.G.H.J.J.J.K.K.K.K.L.L.L.L.", +"I.I.I.I.K.K.K.K.M.M.N.N.O.O.P.P.F.F.G.F.J.J.J.J.K.K.K.K.L.L.L.L."}; diff --git a/textures/wall.xpm b/textures/wall.xpm new file mode 100644 index 0000000..2c8122d --- /dev/null +++ b/textures/wall.xpm @@ -0,0 +1,45 @@ +/* XPM */ +static char *f4be72bda4ec41cce3e231f3563262e6RzcICVlC9CbSzsPX[] = { +/* columns rows colors chars-per-pixel */ +"32 32 7 1 ", +" c #5A595A", +". c gray39", +"X c #6A6D6A", +"o c #787678", +"O c gray50", +"+ c #8B898B", +"@ c #9C999C", +/* pixels */ +"++@@@@@@@@@@@@@@@@@@@@@@@@@@+++ ", +"+oO+++++++++++++++OO++++OO+OOO+ ", +"+O++OO++O++O+++OOOO++OO++OooOo+ ", +"@OOOO+O+++OooO++OO++O+OOOOOooOO ", +"@O+ooO++OOoO++OOOOOOOOOo+OOOOOO ", +"@++OooO++OO++OOOOO+OoO++OOOOOOO ", +"@O+++OoOO+ooOOO+OOooO++OooOooOo ", +"@OoOOOOOOOOOoOOO++OO+OOOOoooOoo ", +"@OOoOoOOOoOOOOOOOOOOOOOOoOOOOOO ", +"@OoooOOooO++OO+OoO+oooOooOO+OOO ", +"@OoXooooOOO+++OOOoooOOoooooO++O ", +"+ooXOoOoOOOoOOOOOOOO++OOXooOOoO ", +"+oXXoOXooooOooooooO+oOXXoooooOO ", +"OoXXXXOOooooooooOoooOOOXXXOOooo ", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.", +".. . ... .............", +"@@@@@@@@@@@@@++ +++@@@@@@@@@@@@@", +"ooOoOO+++++OOOO +OO+O+++O+++OOOO", +"OooOO++O+O++OOO @OOO+++OOOOOOOOO", +"O+O++O++OOOO+OO @OOOOOOO+OOoOO++", +"+OOOOOOOOOOOOOo @oOOO+++OOOOooO+", +"OOOO+OOOO+OOoOo @OoO+ooOoOOOOooO", +"O+OOO+O++OoOooX @oO++OooOOOO+OOO", +"OO+++++OooOoOXX @oOO++OOOoOo++OO", +"OOOO+OO+Oo+OoXX @oOOOOO++ooOOOOO", +"++OOOOOooOooXoX +ooOoO+OO++O+OOO", +"+OooOoOoO++oOoo +oooOOOoOO++OO++", +"OOOooOoOoOXOOoo +OOoOooOoOOOO+OO", +"OoXXoXooXXOOOoo +OooooooOOoOOOoo", +"oooXXooooXXXooo OoOOOoooooOOOOOo", +"XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX", +"............ .............." +};