/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* 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 ** 4: weapon three */ 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_y = 1; plist.dir_x = 0; plist.plane_x = 0; plist.plane_y = 0.66; plist.has_weapon[0] = 0; plist.has_weapon[1] = 0; plist.has_weapon[2] = 0; plist.handles_weapon = -1; plist.ammo[0] = 0; plist.ammo[1] = 0; plist.ammo[2] = 0; plist.life = FT_STRT_LIFE; plist.fire = 0; plist.weap_vel[0] = FT_WEAP_ONE_VEL; plist.weap_vel[1] = FT_WEAP_TWO_VEL; plist.weap_vel[2] = FT_WEAP_THREE_VEL; 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(); cl->currlvl = 0; cl->walltexgood = 0; cl->clickclose = 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 (!(clist->big_t = (float**)ft_calloc(2, sizeof(float*))) || !(clist->big_t[0] = (float*)ft_calloc(1, sizeof(float))) || !(clist->big_t[1] = (float*)ft_calloc(1, sizeof(float)))) return (-1); clist->big_t_val = 2; ft_sprintf(clist->fps_count, "fps: 60"); clist->isdead = 0; clist->moves = 0; clist->life_num_h = 0; clist->life_num_w = 0; clist->life_cap_h = 0; clist->life_cap_w = 0; clist->map_back_h = 0; clist->map_back_w = 0; clist->amm_back_h = 0; clist->amm_back_w = 0; clist->ammo_cap_h = 0; clist->ammo_cap_w = 0; return (0); }