1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_death_hooks.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:28:52 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:28:52 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <mlx.h>
#include <unistd.h>
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);
}
|