diff --git a/Makefile b/Makefile index 17ea4ab..79b9efa 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ SRCS := ${SRCS_MAP} \ OBJS := ${SRCS:.c=.o} CC := clang LIBS := libftx/libftx.a MLX42/build/libmlx42.a -ldl -lglfw -lm -CFLAGS := -g -Wall -Wextra -Werror -Wno-conversion +CFLAGS := -g -Wall -Wextra -Werror -Wno-conversion #-Ofast NAME := cub3D all: ${NAME} diff --git a/game/game.c b/game/game.c index 7f136fa..e488adf 100644 --- a/game/game.c +++ b/game/game.c @@ -6,19 +6,33 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/26 12:59:53 by erey-bet #+# #+# */ -/* Updated: 2023/05/11 16:16:00 by erey-bet ### ########.fr */ +/* Updated: 2023/05/19 17:49:02 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ #include "game.h" -void destroy(t_game *game) +int destroy(t_game *game) { - mlx_delete_texture(game->textures[0]); - mlx_delete_texture(game->textures[1]); - mlx_delete_texture(game->textures[2]); - mlx_delete_texture(game->textures[3]); - mlx_terminate(game->mlx); + if (game->textures[0]) + { + mlx_delete_texture(game->textures[0]); + if (game->textures[1]) + { + mlx_delete_texture(game->textures[1]); + if (game->textures[2]) + { + mlx_delete_texture(game->textures[2]); + if (game->textures[3]) + { + mlx_delete_texture(game->textures[3]); + if (game->mlx) + mlx_terminate(game->mlx); + } + } + } + } + return (1); } int start_game(t_map map) @@ -26,17 +40,17 @@ int start_game(t_map map) t_game game; if (init(map, &game)) - return (1); + return (destroy(&game)); game.window = mlx_new_image(game.mlx, WIDTH, HEIGHT); if (!game.window) { mlx_terminate(game.mlx); - return (1); + return (destroy(&game)); } if (mlx_image_to_window(game.mlx, game.window, 0, 0) == -1) { mlx_terminate(game.mlx); - return (1); + return (destroy(&game)); } raycasting(&game); mlx_key_hook(game.mlx, manage, &game); diff --git a/game/init.c b/game/init.c index eb7f9e6..62c161c 100644 --- a/game/init.c +++ b/game/init.c @@ -6,7 +6,7 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/27 14:50:22 by erey-bet #+# #+# */ -/* Updated: 2023/05/11 15:40:16 by erey-bet ### ########.fr */ +/* Updated: 2023/05/19 17:03:52 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ @@ -55,13 +55,13 @@ int init_textures(t_map map, mlx_texture_t *textures[4]) int init(t_map map, t_game *game) { + if (init_textures(map, game->textures)) + return (2); game->mlx = mlx_init(WIDTH, HEIGHT, "jan lili", true); if (!game->mlx) return (1); game->map = map; init_ply(map, &game->ply); init_ray(&game->ray); - if (init_textures(map, game->textures)) - return (1); return (0); } diff --git a/libftx/extra/extra.a b/libftx/extra/extra.a new file mode 100644 index 0000000..def0c1e Binary files /dev/null and b/libftx/extra/extra.a differ diff --git a/libftx/gnl/get_next_line.a b/libftx/gnl/get_next_line.a new file mode 100644 index 0000000..bc1e015 Binary files /dev/null and b/libftx/gnl/get_next_line.a differ diff --git a/libftx/libft/libft.a b/libftx/libft/libft.a new file mode 100644 index 0000000..2c6a5d9 Binary files /dev/null and b/libftx/libft/libft.a differ diff --git a/libftx/libftx.a b/libftx/libftx.a new file mode 100644 index 0000000..a5b9b54 Binary files /dev/null and b/libftx/libftx.a differ diff --git a/libftx/printf/ft_printf.a b/libftx/printf/ft_printf.a new file mode 100644 index 0000000..adf35b4 Binary files /dev/null and b/libftx/printf/ft_printf.a differ diff --git a/main.c b/main.c index f8b8617..008c044 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/26 12:44:55 by erey-bet #+# #+# */ -/* Updated: 2023/05/05 14:48:45 by cchauvet ### ########.fr */ +/* Updated: 2023/05/19 17:03:29 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,15 +22,12 @@ int main(int argc, char **argv) ft_eprintf("No argument"); return (1); } - if (map_parsing(argv[1], &map)) + if (map_parsing(argv[1], &map) + || start_game(map)) { map_freer(&map); return (2); } - if (start_game(map)) - { - return (3); - } map_freer(&map); return (0); }