From 75c55fd629c8cb83a5d02742c3b3deb9d8d8f490 Mon Sep 17 00:00:00 2001 From: djonker Date: Wed, 1 Nov 2023 14:17:37 +0100 Subject: [PATCH] fixed the slow issue --- Makefile | 6 +++--- Readme.md | 3 ++- src/draw.c | 7 +++---- src/init.c | 2 +- src/main.c | 4 +++- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 07ce8ff..48b9463 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,13 @@ # By: houtworm +#+ # # +#+ # # Created: 2023/10/26 10:46:29 by houtworm #+# #+# # -# Updated: 2023/10/31 15:58:18 by houtworm ######## odam.nl # +# Updated: 2023/11/01 14:10:13 by houtworm ######## odam.nl # # # # **************************************************************************** # NAME =cub3d CC =gcc -FC =-Wall -Werror -Wextra -Wunreachable-code -Ofast -g -fsanitize=address +FC =-Ofast -g -fsanitize=address HEAD =-I ./include -I $(MLX)/include RM =rm -rf LIB =libft/libft.a getnextline/get_next_line.a mlx/build/libmlx42.a -ldl -lglfw -pthread -lm @@ -35,7 +35,7 @@ clean: @$(MAKE) -C mlx/build clean > /dev/null @printf "\e[1;35mCleaned Object Files\n\e[0;00m" -fclean: clean +fclean: clean @$(RM) $(NAME) mlx/build > /dev/null @$(MAKE) -C libft fclean > /dev/null @$(MAKE) -C getnextline fclean > /dev/null diff --git a/Readme.md b/Readme.md index 6aa48dd..c77ae31 100644 --- a/Readme.md +++ b/Readme.md @@ -7,7 +7,7 @@ Cub3D is a simple raycasting game using the mlx library - Flood fill the map starting from the player to check if it is a closed map - Check if all needed elements are present in the closed part of the map ### Raycasting -- Replace walls with textures +- Directional textures ### Bonus - Doors - Minimap @@ -26,6 +26,7 @@ Cub3D is a simple raycasting game using the mlx library - Music? - A Start Menu? - Jumping? +- Crouching? - Vertical Aiming? --- diff --git a/src/draw.c b/src/draw.c index cb8f5ff..815ac77 100644 --- a/src/draw.c +++ b/src/draw.c @@ -6,7 +6,7 @@ /* By: houtworm +#+ */ /* +#+ */ /* Created: 2023/10/26 16:54:20 by houtworm #+# #+# */ -/* Updated: 2023/10/31 16:17:59 by houtworm ######## odam.nl */ +/* Updated: 2023/11/01 14:16:57 by houtworm ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -16,7 +16,7 @@ void ft_drawline(int x, t_varlist *vl, int drawstart, int drawend) { int y; - y = 1; + y = 0; while (y < drawstart) { mlx_put_pixel(vl->img, x, y, vl->ccolor); @@ -35,10 +35,9 @@ void ft_drawline(int x, t_varlist *vl, int drawstart, int drawend) if (vl->side == 1 && vl->raydiry < 0) textx = 64 - textx - 1; double step; - step = 1.0 * 64 / vl->lineheight; + step = 64.0 / vl->lineheight; double textpos; textpos = (drawstart - vl->hoffset - vl->h / 2 + vl->lineheight / 2) * step; - vl->curtext = mlx_load_png(vl->southwt); while (y < drawend) { int texty; diff --git a/src/init.c b/src/init.c index 8b4f18b..a0bb9fb 100644 --- a/src/init.c +++ b/src/init.c @@ -6,7 +6,7 @@ /* By: houtworm +#+ */ /* +#+ */ /* Created: 2023/10/26 16:49:12 by houtworm #+# #+# */ -/* Updated: 2023/10/31 14:24:17 by houtworm ######## odam.nl */ +/* Updated: 2023/11/01 14:14:08 by houtworm ######## odam.nl */ /* */ /* ************************************************************************** */ diff --git a/src/main.c b/src/main.c index 7807d49..3e2c819 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ /* By: houtworm +#+ */ /* +#+ */ /* Created: 2023/10/26 14:13:07 by houtworm #+# #+# */ -/* Updated: 2023/10/29 17:18:22 by houtworm ######## odam.nl */ +/* Updated: 2023/11/01 14:17:09 by houtworm ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -56,6 +56,7 @@ int main(int argc, char **argv) ft_errorexit("Please include a .cub file ", "", 2); // we could start with a menu here if (!vl.img || (mlx_image_to_window(vl.mlx, vl.img, 0, 0) < 0)) ft_errorexit("image to window failed ", "main", 1); + vl.curtext = mlx_load_png(vl.southwt); mlx_key_hook(vl.mlx, &keyhook, &vl); mlx_resize_hook(vl.mlx, &resizehook, &vl); mlx_scroll_hook(vl.mlx, &scrollhook, &vl); @@ -63,6 +64,7 @@ int main(int argc, char **argv) mlx_cursor_hook(vl.mlx, &cursorhook, &vl); mlx_loop_hook(vl.mlx, &mainloop, &vl); mlx_loop(vl.mlx); + mlx_delete_texture(vl.curtext); mlx_delete_image(vl.mlx, vl.img); mlx_terminate(vl.mlx); exit (0);