diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_get_player_spawn.c | 60 |
1 files changed, 50 insertions, 10 deletions
diff --git a/src/ft_get_player_spawn.c b/src/ft_get_player_spawn.c index 74e2231..c848872 100644 --- a/src/ft_get_player_spawn.c +++ b/src/ft_get_player_spawn.c @@ -12,20 +12,60 @@ #include <libft.h> #include <cub3d.h> +#include <math.h> #include <stdint.h> -static uint8_t - ft_get_view_side(char c) +static void + ft_get_e_dir(t_player *pl) { - if (c == 'N') - return (1); - else if (c == 'E') - return (2); + float sav_dir_x; + float sav_plane_x; + + sav_dir_x = pl->dir_x; + pl->dir_x = pl->dir_y; + pl->dir_y = sav_dir_x; + sav_plane_x = pl->plane_x; + pl->plane_x = pl->plane_y; + pl->plane_y = sav_plane_x; +} + +static void + ft_get_s_dir(t_player *pl) +{ + float sav_dir_x; + float sav_plane_x; + + sav_dir_x = pl->dir_x; + pl->dir_x = -pl->dir_x; + pl->dir_y = -pl->dir_y; + sav_plane_x = pl->plane_x; + pl->plane_x = -pl->plane_x; + pl->plane_y = -pl->plane_y; +} + +static void + ft_get_w_dir(t_player *pl) +{ + float sav_dir_x; + float sav_plane_x; + + sav_dir_x = pl->dir_x; + pl->dir_x = -pl->dir_y; + pl->dir_y = -sav_dir_x; + sav_plane_x = pl->plane_x; + pl->plane_x = -pl->plane_y; + pl->plane_y = -sav_plane_x; +} + +static void + ft_get_start_side(char c, t_player *pl) +{ + if (c == 'E') + ft_get_e_dir(pl); else if (c == 'S') - return (3); + ft_get_s_dir(pl); else if (c == 'W') - return (4); - return (1); + ft_get_w_dir(pl); } void @@ -44,7 +84,7 @@ void { plist->pos_x = x; plist->pos_y = y; - plist->view_side = ft_get_view_side(clist->mlist->map[y][x]); + ft_get_start_side(clist->mlist->map[y][x], clist->plist); return ; } x++; |