diff --git a/MacroLibX b/MacroLibX index 3dd68f9..4d640ed 160000 --- a/MacroLibX +++ b/MacroLibX @@ -1 +1 @@ -Subproject commit 3dd68f994248bfa6e6c634ca9c838dfe48b53520 +Subproject commit 4d640ed70cd392f3e3311fe2779905876b7f1b6f diff --git a/Makefile b/Makefile index f03bf76..6e1935a 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: adjoly +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/10/07 16:02:18 by adjoly #+# #+# # -# Updated: 2024/10/08 21:44:52 by adjoly ### ########.fr # +# Updated: 2024/10/08 22:06:26 by adjoly ### ########.fr # # # # **************************************************************************** # @@ -14,7 +14,7 @@ SHELL = bash NAME = cub3D -CC = clang +CC = gcc OBJSDIR = obj/ diff --git a/includes/game/dda.h b/includes/game/dda.h index 0840146..f0bc797 100644 --- a/includes/game/dda.h +++ b/includes/game/dda.h @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/04 14:04:10 by adjoly #+# #+# */ -/* Updated: 2024/10/07 17:42:00 by adjoly ### ########.fr */ +/* Updated: 2024/10/13 17:44:12 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ * @param player The address of the t_player struct * @param dda The address of the t_dda struct */ -void get_ray_angle(t_player *player, t_dda (*dda)[800]); +void get_ray_angle(t_player *player, t_dda (*dda)[800]); /** * @brief Function used to setup all the dda variable prior to casting @@ -31,7 +31,7 @@ void get_ray_angle(t_player *player, t_dda (*dda)[800]); * @param dda The address of the t_dda struct * */ -void setup_dda(t_dda (*dda)[800], t_player *player); +void setup_dda(t_dda (*dda)[800], t_player *player); /** * @brief Function used to cast all the rays @@ -40,6 +40,21 @@ void setup_dda(t_dda (*dda)[800], t_player *player); * @param map The map as a char ** * @param map_coord The coordinate of the player on the map_grid */ -void while_dda(t_dda (*dda)[800], char **map, t_coord map_coord); +void while_dda(t_dda (*dda)[800], char **map, t_coord map_coord); + + /// NEED TO COMBINE THOSE IF NOT USEFULL TO SEPARATE +/** + * @brief Function used to get the distance from the player of all rays + * + * @param dda The address of the t_dda struct + */ +float *dist_dda(t_dda dda[WINDOW_X / RAY_SIZE]); + +/** + * @brief Function used to get the size of the line to be printed on the screen + * + * @param dda The array of the all the distance to the wall of the rays + */ +uint16_t *line_dda(float *wall_dist); #endif diff --git a/src/raycasting/dda/dda.c b/src/raycasting/dda/dda.c index d826ac4..08485f2 100644 --- a/src/raycasting/dda/dda.c +++ b/src/raycasting/dda/dda.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/07 16:55:09 by adjoly #+# #+# */ -/* Updated: 2024/10/08 13:59:15 by adjoly ### ########.fr */ +/* Updated: 2024/10/13 17:27:17 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,18 +18,18 @@ void dda(t_player *player, char **map) t_dda dda[WINDOW_X / RAY_SIZE]; t_coord map_coord; float *wall_dist; + float *line_size; setup_dda(&dda, player); map_coord.x = player->coords.x - player->coords.x % MAP_CHUNK_SIZE; map_coord.y = player->coords.y - player->coords.y % MAP_CHUNK_SIZE; while_dda(&dda, map, map_coord); wall_dist = dist_dda(dda); + } /** * calculate size on screen * screen_height / per_wall_dist -* -* print on screen -* +* (and get orientation) */ diff --git a/src/raycasting/dda/line_dda.c b/src/raycasting/dda/line_dda.c new file mode 100644 index 0000000..cbc171c --- /dev/null +++ b/src/raycasting/dda/line_dda.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* line_dda.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/10/13 17:27:44 by adjoly #+# #+# */ +/* Updated: 2024/10/13 17:36:05 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "game/settings.h" + +uint16_t *line_dda(t_dda (*dda)[WINDOW_X / RAY_SIZE], float *wall_dist) +{ + uint16_t i; + uint16_t *line_size; + + (void)dda; + i = 0; + line_size = malloc(WINDOW_X / RAY_SIZE * sizeof(uint16_t)); + while (wall_dist[i]) + { + line_size[i] = (WINDOW_Y / wall_dist[i]); + i++; + } + return (line_size); +} diff --git a/src/raycasting/ray_calc.c b/src/raycasting/ray_calc.c deleted file mode 100644 index e69de29..0000000