/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_init_lists.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:28:53 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:28:53 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include #include #include #include t_rgb ft_init_rgb(void) { t_rgb rgb; rgb.r = -1; rgb.g = -1; rgb.b = -1; return (rgb); } static t_player *ft_init_player(void) { t_player *plist; if (!(plist = (t_player*)malloc(sizeof(t_player)))) return (NULL); plist.pos_x = 0; plist.pos_y = 0; plist.start_x = 0; plist.start_y = 0; plist.cam_x = 0; plist.dir_x = -1; plist.dir_y = 0; plist.plane_x = 0; plist.plane_y = 0.75; return (plist); } static t_win *ft_init_win(void) { t_win *wlist; if (!(wlist = (t_win*)malloc(sizeof(t_win)))) return (NULL); if (!(wlist.winptr = malloc(1))) return (NULL); wlist.inited = 0; wlist.x_size = 0; wlist.y_size = 0; wlist.x_max_size = 0; wlist.y_max_size = 0; return (wlist); } static t_cub ft_init_cub(void) { t_cub clist; uint8_t i; if (!(clist.plist = ft_init_player()) || !(clist.mlist = ft_init_map())) return (NULL); ft_bzero(clist.errmsg, 40); i = -1; while (++i < 5) clist.key_input[i] = -1; clist.ishud = 0; clist.isoldmus = 0; clist.f_rgb = ft_init_rgb(); clist.c_rgb = ft_init_rgb(); clist.rlist = ft_init_s_ray(); clist.currlvl = 0; clist.walltexgood = 0; ft_init_funptr(clist); return (clist); } t_cub ft_init_cub3d(void) { t_cub cl; if (!(cl = ft_init_cub())) return (NULL); if (!(cl.wlist = ft_init_win())) { ft_memdel((void**)&cl.wlist); ft_memdel((void**)&cl); return (NULL); } return (cl); }