/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* 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 t_rgb ft_init_rgb(void) { t_rgb rgb; rgb.r = -1; rgb.g = -1; rgb.b = -1; return (rgb); } /* ** handles_weapon ** -------------- ** -1: no weapon ** 0: weapon one ** 2: weapon two */ t_player ft_init_player(void) { t_player plist; plist.pos_x = 0; plist.pos_y = 0; plist.pos_z = 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.66; plist.has_weapon[0] = 0; plist.has_weapon[1] = 0; plist.handles_weapon = -1; plist.life = FT_STRT_LIFE; plist.fire = 0; return (plist); } static int8_t ft_init_win(t_win *wl) { if (!(wl->wlx = malloc(1))) return (-1); if (!(wl->winptr = malloc(1))) return (-1); wl->inited = 0; wl->x_size = 0; wl->y_size = 0; wl->x_max_size = 0; wl->y_max_size = 0; return (0); } static int8_t ft_init_cub(t_cub *cl) { int8_t i; if (ft_init_map(&cl->mlist) < 0) return (-1); cl->plist = ft_init_player(); ft_bzero(cl->errmsg, 40); i = -1; while (++i < 5) cl->key_input[i] = -1; cl->mtid = 0; cl->ishud = 0; cl->isoldmus = 0; cl->doicast = 1; cl->f_rgb = ft_init_rgb(); cl->c_rgb = ft_init_rgb(); cl->rlist = ft_init_s_ray(); if (ft_init_sfx(cl) < 0) return (-1); cl->currlvl = 0; cl->walltexgood = 0; ft_init_funptr(cl); ft_init_ref(cl); return (0); } int8_t ft_init_cub3d(t_cub *clist) { if (ft_init_cub(clist) < 0) return (-1); if (ft_init_win(&clist->wlist) < 0) return (-1); if (ft_init_sprites(&clist->sprites) < 0) return (-1); if (ft_init_weaps(&clist->weaps) < 0) return (-1); ft_sprintf(clist->fps_count, "fps: 60"); clist->isdead = 0; clist->moves = 0; clist->h = 0; clist->w = 0; return (0); }