/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_get_player_spawn.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: joelecle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:28:47 by joelecle #+# #+# */ /* Updated: 2020/02/14 17:28:47 by joelecle ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include static void ft_get_s_dir(t_player *pl) { pl->dir_y = -pl->dir_y; pl->dir_x = -pl->dir_x; pl->plane_x = -pl->plane_x; pl->plane_y = -pl->plane_y; } static void ft_get_e_dir(t_player *pl) { float sav_dir_y; float sav_plane_x; sav_dir_y = pl->dir_y; pl->dir_y = -pl->dir_x; pl->dir_x = -sav_dir_y; sav_plane_x = pl->plane_x; pl->plane_x = -pl->plane_y; pl->plane_y = sav_plane_x; } static void ft_get_w_dir(t_player *pl) { float sav_dir_y; float sav_plane_x; sav_dir_y = pl->dir_y; pl->dir_y = pl->dir_x; pl->dir_x = sav_dir_y; 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_w_dir(pl); else if (c == 'S') ft_get_s_dir(pl); else if (c == 'W') ft_get_e_dir(pl); } void ft_get_player_spawn(t_player *plist, t_cub *clist) { size_t x; size_t y; x = 1; y = 1; while (clist->mlist.map[y]) { while (clist->mlist.map[y][x]) { if (ft_ischarset(FT_CHRST_SPAWN, clist->mlist.map[y][x])) { plist->pos_x = x + 0.5; plist->pos_y = y + 0.5; plist->start_x = plist->pos_x; plist->start_y = plist->pos_y; ft_get_start_side(clist->mlist.map[y][x], plist); return ; } x++; } x = 1; y++; } }