/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_death_hooks.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:28:52 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:28:52 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include static int ft_death_key_event(int keycode, t_cub *clist) { const int32_t tmp_code = keycode; keycode = ft_convert_keycode(tmp_code); if (keycode == FT_ESC_KEY) return (ft_exit(0, (clist))); if (keycode == FT_RET_KEY) { if (ft_warp_level(clist->mlist.filename, clist) < 0) return (ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, clist)); ft_draw_scene(clist); ft_hooks_and_loops(&clist->wlist, clist); return (0); } return (0); } static int ft_death_key_loop(t_cub *cl) { (void)cl; return (0); /* uint8_t i; */ /* const float old_y = cl->plist.pos_y; */ /* const float old_x = cl->plist.pos_x; */ /* i = 0; */ /* while (i < 5 && cl->key_input[i] != -1 && cl->key_input[i] <= 5) */ /* { */ /* cl->key_ptr[cl->key_input[i]](cl); */ /* ft_collision(old_y, old_x, cl->key_input[i], cl); */ /* if (cl->mlist.isnlvl) */ /* { */ /* if ((uint32_t)cl->plist.pos_x == cl->mlist.nlx && */ /* (uint32_t)cl->plist.pos_y == cl->mlist.nly) */ /* { */ /* ft_sfx_new_level(cl); */ /* return ((ft_warp_level(cl->mlist.nlevel_path, cl) < 0) ? */ /* (ft_exit(FT_RET_FAILED_STRUCTS, cl)) : (0)); */ /* } */ /* } */ /* i++; */ /* } */ /* if (cl->key_input[0] != -1) */ /* ft_draw_scene(cl); */ /* return (0); */ } void ft_death_hooks(t_win *wl, t_cub *cl) { mlx_hook(wl->winptr, 2, (1L << 0), ft_death_key_event, cl); mlx_loop_hook(wl->wlx, ft_death_key_loop, cl); mlx_loop(wl->wlx); }