Skip to content

Commit

Permalink
Removed raycasting.h and did some clean up in header dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsunghao-C committed Sep 2, 2024
1 parent f0a5838 commit 21b8cd2
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 51 deletions.
11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jteissie <jteissie@student.42.fr> +#+ +:+ +#+ #
# By: tsuchen <tsuchen@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# 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 #
# #
# **************************************************************************** #

Expand All @@ -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 \
Expand All @@ -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

Expand All @@ -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)

Expand Down
14 changes: 9 additions & 5 deletions includes/cub3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* cub3d.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <jteissie@student.42.fr> +#+ +:+ +#+ */
/* By: tsuchen <tsuchen@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -35,7 +35,6 @@

# include "parser.h"
# include "vector.h"
# include "raycasting.h"

# define SUCCESS 0
# define PANIC 1
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand Down
27 changes: 0 additions & 27 deletions includes/raycasting.h

This file was deleted.

4 changes: 1 addition & 3 deletions includes/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Expand All @@ -19,8 +19,6 @@
# include <stdlib.h>
# include <stdint.h>

# define PI 3.14159265359f

typedef struct s_vec
{
double x;
Expand Down
2 changes: 1 addition & 1 deletion maps/subject_test.cub
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions srcs/raycasting/raycasting.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
/* ::: :::::::: */
/* raycasting.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <jteissie@student.42.fr> +#+ +:+ +#+ */
/* By: tsuchen <tsuchen@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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)
{
Expand Down
6 changes: 3 additions & 3 deletions srcs/render_utils.c → srcs/raycasting/render_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* render_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <jteissie@student.42.fr> +#+ +:+ +#+ */
/* By: tsuchen <tsuchen@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -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);
}
}
6 changes: 3 additions & 3 deletions srcs/raycasting/render_wall.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* render_wall.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <jteissie@student.42.fr> +#+ +:+ +#+ */
/* By: tsuchen <tsuchen@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 21b8cd2

Please sign in to comment.