Skip to content

Commit

Permalink
removed redundent spwan_dir and p_dir_default
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsunghao-C committed Aug 29, 2024
1 parent 560309f commit 492df5b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 21 deletions.
11 changes: 1 addition & 10 deletions includes/cub3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -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
{
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion srcs/game_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

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

Expand All @@ -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])
Expand Down
6 changes: 1 addition & 5 deletions srcs/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

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

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

0 comments on commit 492df5b

Please sign in to comment.