From 492df5b9631df95f3312a1c697647d245746f01c Mon Sep 17 00:00:00 2001 From: Tsunghao Date: Thu, 29 Aug 2024 17:52:48 +0200 Subject: [PATCH] removed redundent spwan_dir and p_dir_default --- includes/cub3d.h | 11 +---------- srcs/game_init.c | 2 +- srcs/main.c | 3 +-- srcs/parser/parser.c | 6 +----- srcs/parser/parser_utils.c | 6 +++--- 5 files changed, 7 insertions(+), 21 deletions(-) diff --git a/includes/cub3d.h b/includes/cub3d.h index 21c72e5..31006cf 100644 --- a/includes/cub3d.h +++ b/includes/cub3d.h @@ -6,7 +6,7 @@ /* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/15 00:19:44 by tsuchen #+# #+# */ -/* Updated: 2024/08/29 16:57:43 by tsuchen ### ########.fr */ +/* Updated: 2024/08/29 17:49:31 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -89,13 +89,6 @@ typedef enum e_move RIGHT, LEFT, } t_move; -typedef enum e_p_dir -{ - NORTH = 'N', - SOUTH = 'S', - WEST = 'W', - EAST = 'E', -} t_p_dir; typedef struct s_image { @@ -117,11 +110,9 @@ typedef struct s_data void *window; t_image image; t_textdata *textures; - t_p_dir p_dir_default; t_vec p_pos; t_vec p_dir; t_vec p_cam; - t_p_dir spawn_dir; } t_data; int cleanup(t_data *data); diff --git a/srcs/game_init.c b/srcs/game_init.c index 58b4cc8..5dd2ddd 100644 --- a/srcs/game_init.c +++ b/srcs/game_init.c @@ -6,7 +6,7 @@ /* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/27 17:03:43 by jteissie #+# #+# */ -/* Updated: 2024/08/29 17:01:29 by tsuchen ### ########.fr */ +/* Updated: 2024/08/29 17:52:04 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/srcs/main.c b/srcs/main.c index 42732ab..55a2e3a 100644 --- a/srcs/main.c +++ b/srcs/main.c @@ -6,7 +6,7 @@ /* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/15 12:03:33 by tsuchen #+# #+# */ -/* Updated: 2024/08/29 16:37:04 by tsuchen ### ########.fr */ +/* Updated: 2024/08/29 17:48:44 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,6 @@ // i = 0; // printf("Player position x: %.2f, y: %.2f\n", data->p_pos.x, data->p_pos.y); // printf("Player direction x: %.2f, y: %.2f\n", data->p_dir.x, data->p_dir.y); -// printf("Player default dir: %d\n", data->p_dir_default); // printf("Map path is: %s\n", data->map_path); // printf("Map output:\n"); // while (data->map[i]) diff --git a/srcs/parser/parser.c b/srcs/parser/parser.c index 064997c..2344ce4 100644 --- a/srcs/parser/parser.c +++ b/srcs/parser/parser.c @@ -6,7 +6,7 @@ /* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/15 12:12:00 by tsuchen #+# #+# */ -/* Updated: 2024/08/29 10:55:16 by tsuchen ### ########.fr */ +/* Updated: 2024/08/29 17:49:49 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,25 +40,21 @@ static void get_player_dir(t_data *data, u_int32_t x, u_int32_t y) { if (data->map[x][y] == 'N') { - data->p_dir_default = NORTH; vec_init(&data->p_dir, -1.0f, 0.0f); vec_init(&data->p_cam, 0.0f, tan(FOV / 2)); } else if (data->map[x][y] == 'S') { - data->p_dir_default = SOUTH; vec_init(&data->p_dir, 1.0f, 0.0f); vec_init(&data->p_cam, 0.0f, tan(FOV / 2) * -1); } else if (data->map[x][y] == 'W') { - data->p_dir_default = WEST; vec_init(&data->p_dir, 0.0f, -1.0f); vec_init(&data->p_cam, tan(FOV / 2) * -1, 0.0f); } else if (data->map[x][y] == 'E') { - data->p_dir_default = EAST; vec_init(&data->p_dir, 0.0f, 1.0f); vec_init(&data->p_cam, tan(FOV / 2), 0.0f); } diff --git a/srcs/parser/parser_utils.c b/srcs/parser/parser_utils.c index 9a3bebf..732a7b4 100644 --- a/srcs/parser/parser_utils.c +++ b/srcs/parser/parser_utils.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* parser_utils.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ +/* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/16 18:12:37 by jteissie #+# #+# */ -/* Updated: 2024/08/28 17:45:05 by jteissie ### ########.fr */ +/* Updated: 2024/08/29 17:50:54 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -66,7 +66,7 @@ void fill_whitespaces(char **map) static uint32_t is_cardinal_pos(char c) { - return (c == NORTH || c == SOUTH || c == WEST || c == EAST); + return (c == 'N' || c == 'S' || c == 'W' || c == 'E'); } t_parse_status find_start(uint32_t coordinate[], char **map, size_t map_start)