diff options
author | Rudy Bousset <rbousset@z2r4p1.le-101.fr> | 2020-02-14 21:00:02 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r4p1.le-101.fr> | 2020-02-14 21:00:02 +0100 |
commit | a95f7c219961b16be72febd645191e5a0d4aad4d (patch) | |
tree | a3a49e80b550742e4f9c5fe890bb6ef76ad2486e /src/ft_get_player_spawn.c | |
parent | New define .h (diff) | |
download | 42-cub3d-a95f7c219961b16be72febd645191e5a0d4aad4d.tar.gz 42-cub3d-a95f7c219961b16be72febd645191e5a0d4aad4d.tar.bz2 42-cub3d-a95f7c219961b16be72febd645191e5a0d4aad4d.tar.xz 42-cub3d-a95f7c219961b16be72febd645191e5a0d4aad4d.tar.zst 42-cub3d-a95f7c219961b16be72febd645191e5a0d4aad4d.zip |
Good player spawn view for N and S, minimap bot left StarCraft style
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++; |