/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_get_player_spawn.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:28:47 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:28:47 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include static uint8_t ft_get_view_side(char c) { if (c == 'N') return (1); else if (c == 'E') return (2); else if (c == 'S') return (3); else if (c == 'W') return (4); return (1); } 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("NSEW", clist->mlist->map[y][x])) { plist->pos_x = x; plist->pos_y = y; plist->view_side = ft_get_view_side(clist->mlist->map[y][x]); return ; } x++; } x = 1; y++; } }