fixed the slow issue

This commit is contained in:
djonker 2023-11-01 14:17:37 +01:00
parent cf86f2d23f
commit 75c55fd629
5 changed files with 12 additions and 10 deletions

View File

@ -6,13 +6,13 @@
# By: houtworm <codam@houtworm.net> +#+ #
# +#+ #
# 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

View File

@ -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?
---

View File

@ -6,7 +6,7 @@
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* 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;

View File

@ -6,7 +6,7 @@
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* 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 */
/* */
/* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* 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);