fixed the slow issue
This commit is contained in:
parent
cf86f2d23f
commit
75c55fd629
4
Makefile
4
Makefile
@ -6,13 +6,13 @@
|
|||||||
# By: houtworm <codam@houtworm.net> +#+ #
|
# By: houtworm <codam@houtworm.net> +#+ #
|
||||||
# +#+ #
|
# +#+ #
|
||||||
# Created: 2023/10/26 10:46:29 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
|
NAME =cub3d
|
||||||
CC =gcc
|
CC =gcc
|
||||||
FC =-Wall -Werror -Wextra -Wunreachable-code -Ofast -g -fsanitize=address
|
FC =-Ofast -g -fsanitize=address
|
||||||
HEAD =-I ./include -I $(MLX)/include
|
HEAD =-I ./include -I $(MLX)/include
|
||||||
RM =rm -rf
|
RM =rm -rf
|
||||||
LIB =libft/libft.a getnextline/get_next_line.a mlx/build/libmlx42.a -ldl -lglfw -pthread -lm
|
LIB =libft/libft.a getnextline/get_next_line.a mlx/build/libmlx42.a -ldl -lglfw -pthread -lm
|
||||||
|
@ -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
|
- 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
|
- Check if all needed elements are present in the closed part of the map
|
||||||
### Raycasting
|
### Raycasting
|
||||||
- Replace walls with textures
|
- Directional textures
|
||||||
### Bonus
|
### Bonus
|
||||||
- Doors
|
- Doors
|
||||||
- Minimap
|
- Minimap
|
||||||
@ -26,6 +26,7 @@ Cub3D is a simple raycasting game using the mlx library
|
|||||||
- Music?
|
- Music?
|
||||||
- A Start Menu?
|
- A Start Menu?
|
||||||
- Jumping?
|
- Jumping?
|
||||||
|
- Crouching?
|
||||||
- Vertical Aiming?
|
- Vertical Aiming?
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 16:54:20 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;
|
int y;
|
||||||
|
|
||||||
y = 1;
|
y = 0;
|
||||||
while (y < drawstart)
|
while (y < drawstart)
|
||||||
{
|
{
|
||||||
mlx_put_pixel(vl->img, x, y, vl->ccolor);
|
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)
|
if (vl->side == 1 && vl->raydiry < 0)
|
||||||
textx = 64 - textx - 1;
|
textx = 64 - textx - 1;
|
||||||
double step;
|
double step;
|
||||||
step = 1.0 * 64 / vl->lineheight;
|
step = 64.0 / vl->lineheight;
|
||||||
double textpos;
|
double textpos;
|
||||||
textpos = (drawstart - vl->hoffset - vl->h / 2 + vl->lineheight / 2) * step;
|
textpos = (drawstart - vl->hoffset - vl->h / 2 + vl->lineheight / 2) * step;
|
||||||
vl->curtext = mlx_load_png(vl->southwt);
|
|
||||||
while (y < drawend)
|
while (y < drawend)
|
||||||
{
|
{
|
||||||
int texty;
|
int texty;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 16:49:12 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 14:13:07 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
|
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))
|
if (!vl.img || (mlx_image_to_window(vl.mlx, vl.img, 0, 0) < 0))
|
||||||
ft_errorexit("image to window failed ", "main", 1);
|
ft_errorexit("image to window failed ", "main", 1);
|
||||||
|
vl.curtext = mlx_load_png(vl.southwt);
|
||||||
mlx_key_hook(vl.mlx, &keyhook, &vl);
|
mlx_key_hook(vl.mlx, &keyhook, &vl);
|
||||||
mlx_resize_hook(vl.mlx, &resizehook, &vl);
|
mlx_resize_hook(vl.mlx, &resizehook, &vl);
|
||||||
mlx_scroll_hook(vl.mlx, &scrollhook, &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_cursor_hook(vl.mlx, &cursorhook, &vl);
|
||||||
mlx_loop_hook(vl.mlx, &mainloop, &vl);
|
mlx_loop_hook(vl.mlx, &mainloop, &vl);
|
||||||
mlx_loop(vl.mlx);
|
mlx_loop(vl.mlx);
|
||||||
|
mlx_delete_texture(vl.curtext);
|
||||||
mlx_delete_image(vl.mlx, vl.img);
|
mlx_delete_image(vl.mlx, vl.img);
|
||||||
mlx_terminate(vl.mlx);
|
mlx_terminate(vl.mlx);
|
||||||
exit (0);
|
exit (0);
|
||||||
|
Loading…
Reference in New Issue
Block a user