From 21b8cd2b382166e8b1d6e1ca64799143435627c9 Mon Sep 17 00:00:00 2001 From: Tsunghao Date: Mon, 2 Sep 2024 10:41:51 +0200 Subject: [PATCH] Removed raycasting.h and did some clean up in header dependencies --- Makefile | 11 +++++------ includes/cub3d.h | 14 +++++++++----- includes/raycasting.h | 27 --------------------------- includes/vector.h | 4 +--- maps/subject_test.cub | 2 +- srcs/raycasting/raycasting.c | 6 +++--- srcs/{ => raycasting}/render_utils.c | 6 +++--- srcs/raycasting/render_wall.c | 6 +++--- 8 files changed, 25 insertions(+), 51 deletions(-) delete mode 100644 includes/raycasting.h rename srcs/{ => raycasting}/render_utils.c (88%) diff --git a/Makefile b/Makefile index c7b5023..ec95d17 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,10 @@ # ::: :::::::: # # Makefile :+: :+: :+: # # +:+ +:+ +:+ # -# By: jteissie +#+ +:+ +#+ # +# By: tsuchen +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/08/15 12:02:08 by tsuchen #+# #+# # -# Updated: 2024/08/29 17:50:17 by jteissie ### ########.fr # +# Updated: 2024/09/02 10:37:49 by tsuchen ### ########.fr # # # # **************************************************************************** # @@ -15,8 +15,7 @@ NAME = cub3d SRCS_M = main.c \ game_init.c \ cleanup.c \ - color_utils.c \ - render_utils.c + color_utils.c SRCS_PS = parser.c \ @@ -29,7 +28,7 @@ SRCS_EV = key_events.c SRCS_MAP = map.c -SRCS_RC = raycasting.c render_wall.c +SRCS_RC = raycasting.c render_wall.c render_utils.c SRCS_VEC = vector.c vector_2.c vector_3.c @@ -47,7 +46,7 @@ SRCS = $(addprefix $(PATH_M), $(SRCS_M)) \ $(addprefix $(PATH_RC), $(SRCS_RC)) \ $(addprefix $(PATH_VEC), $(SRCS_VEC)) -HEADERS = cub3d.h parser.h vector.h raycasting.h +HEADERS = cub3d.h parser.h vector.h OBJS = $(SRCS:.c=.o) diff --git a/includes/cub3d.h b/includes/cub3d.h index 58de66d..22cf057 100644 --- a/includes/cub3d.h +++ b/includes/cub3d.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* cub3d.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ +/* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/15 00:19:44 by tsuchen #+# #+# */ -/* Updated: 2024/08/30 15:28:06 by jteissie ### ########.fr */ +/* Updated: 2024/09/02 10:38:43 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,7 +35,6 @@ # include "parser.h" # include "vector.h" -# include "raycasting.h" # define SUCCESS 0 # define PANIC 1 @@ -48,7 +47,7 @@ # define WIDTH 1280 # define HEIGHT 720 # define FOV 90 -# define ROT_STEP 1.0f +# define ROT_STEP 1.5f # define MOV_STEP 0.1f # define KEY_PRESS 2 # define MOUSE_PRESS 4 @@ -131,7 +130,12 @@ int create_trgb(int t, int r, int g, int b); int get_color(int trgb, char index); int add_shade(double factor, int color); int get_opposite(int color); -/* rendering utils*/ +/* RC Rendering */ +int rc_dda(t_vec *dist, t_vec *unit_dist, t_vec *pos, t_vec *dir); +void rc_ray_init(t_vec *dist, t_vec *pos, t_vec *dir, t_vec *unit_dst); +double rc_raydist(t_vec *ray, t_data *data); +int rc_rendering(t_data *data); +void rc_render_wall(t_data *data, int x, int y, double ray_dist); void rc_mlx_pixel_put(t_image *image, int x, int y, int color); void rc_stripe_pixel_put(t_data *data, int x, double ray_dist); diff --git a/includes/raycasting.h b/includes/raycasting.h deleted file mode 100644 index 637d77b..0000000 --- a/includes/raycasting.h +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* raycasting.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/08/27 17:39:13 by tsuchen #+# #+# */ -/* Updated: 2024/08/29 17:49:38 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef RAYCASTING_H -# define RAYCASTING_H - -# include "vector.h" -# include "cub3d.h" - -typedef struct s_data t_data; - -int rc_dda(t_vec *dist, t_vec *unit_dist, t_vec *pos, t_vec *dir); -void rc_ray_init(t_vec *dist, t_vec *pos, t_vec *dir, t_vec *unit_dst); -double rc_raydist(t_vec *ray, t_data *data); -int rc_rendering(t_data *data); -void mlx_render_wall(t_data *data, int x, int y, double ray_dist); - -#endif diff --git a/includes/vector.h b/includes/vector.h index ecd7556..68159d9 100644 --- a/includes/vector.h +++ b/includes/vector.h @@ -6,7 +6,7 @@ /* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/27 10:56:32 by tsuchen #+# #+# */ -/* Updated: 2024/08/29 16:43:25 by tsuchen ### ########.fr */ +/* Updated: 2024/09/02 10:40:39 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,8 +19,6 @@ # include # include -# define PI 3.14159265359f - typedef struct s_vec { double x; diff --git a/maps/subject_test.cub b/maps/subject_test.cub index b8f4cb9..11d567a 100644 --- a/maps/subject_test.cub +++ b/maps/subject_test.cub @@ -1,6 +1,6 @@ NO ./assets/okan.xpm SO ./assets/yohurteb.xpm -WE ./assets/dexi.xpm +WE ./assets/yohurteb.xpm EA ./assets/okan.xpm F 220,100,0 diff --git a/srcs/raycasting/raycasting.c b/srcs/raycasting/raycasting.c index a5e27c5..721f1f7 100644 --- a/srcs/raycasting/raycasting.c +++ b/srcs/raycasting/raycasting.c @@ -3,14 +3,14 @@ /* ::: :::::::: */ /* raycasting.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ +/* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/15 12:13:34 by tsuchen #+# #+# */ -/* Updated: 2024/08/29 17:45:05 by jteissie ### ########.fr */ +/* Updated: 2024/09/02 10:37:34 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ -#include "raycasting.h" +#include "cub3d.h" void rc_ray_init(t_vec *dist, t_vec *pos, t_vec *dir, t_vec *unit_dst) { diff --git a/srcs/render_utils.c b/srcs/raycasting/render_utils.c similarity index 88% rename from srcs/render_utils.c rename to srcs/raycasting/render_utils.c index a080ee0..661496e 100644 --- a/srcs/render_utils.c +++ b/srcs/raycasting/render_utils.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* render_utils.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ +/* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/29 12:12:17 by tsuchen #+# #+# */ -/* Updated: 2024/08/30 14:37:39 by jteissie ### ########.fr */ +/* Updated: 2024/09/02 10:33:39 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,6 +34,6 @@ void rc_stripe_pixel_put(t_data *data, int x, double ray_dist) else if (y > (HEIGHT + wall_height) / 2) rc_mlx_pixel_put(&data->image, x, y, data->textures->floor); else - mlx_render_wall(data, x, y, ray_dist); + rc_render_wall(data, x, y, ray_dist); } } diff --git a/srcs/raycasting/render_wall.c b/srcs/raycasting/render_wall.c index ad53637..8c488ec 100644 --- a/srcs/raycasting/render_wall.c +++ b/srcs/raycasting/render_wall.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* render_wall.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ +/* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/29 14:22:08 by jteissie #+# #+# */ -/* Updated: 2024/08/30 16:04:06 by jteissie ### ########.fr */ +/* Updated: 2024/09/02 10:33:28 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -64,7 +64,7 @@ static void get_y_coordinate(int *tex_pos, t_data *data, int wall_height, int y) tex_pos[1] = data->textures->tex_h[dir] - 1; } -void mlx_render_wall(t_data *data, int x, int y, double ray_dist) +void rc_render_wall(t_data *data, int x, int y, double ray_dist) { t_wall w_data; t_textdata *tex;