-
Notifications
You must be signed in to change notification settings - Fork 2
/
hook.c
75 lines (69 loc) · 2.01 KB
/
hook.c
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
75
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* hook.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vvinogra <vvinogra@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/03/05 17:50:14 by vvinogra #+# #+# */
/* Updated: 2018/03/14 13:37:19 by vvinogra ### ########.fr */
/* */
/* ************************************************************************** */
#include "wolf.h"
int loop_hook(t_wolf *wolf)
{
image_clear(wolf->ret_im);
move(wolf);
solution(wolf);
mlx_put_image_to_window(wolf->mlx, wolf->win, wolf->ret_im->image, 0, 0);
anim_shotgun(wolf);
return (0);
}
int exit_x(void *par)
{
par = NULL;
exit(0);
return (0);
}
int exit_esc(int keycode, t_wolf *wolf)
{
if (keycode == 53)
{
mlx_destroy_window(wolf->mlx, wolf->win);
exit(0);
}
return (0);
}
int hook(int keycode, t_wolf *wolf)
{
exit_esc(keycode, wolf);
if (keycode == 123)
wolf->move->move_left = 1;
if (keycode == 124)
wolf->move->move_right = 1;
if (keycode == 125)
wolf->move->move_back = 1;
if (keycode == 126)
wolf->move->move_forward = 1;
if (keycode == 257)
wolf->ray->move_speed = 0.1;
return (0);
}
int exposehook(int keycode, t_wolf *wolf)
{
exit_esc(keycode, wolf);
if (keycode == 123)
wolf->move->move_left = 0;
if (keycode == 124)
wolf->move->move_right = 0;
if (keycode == 125)
wolf->move->move_back = 0;
if (keycode == 126)
wolf->move->move_forward = 0;
if (keycode == 257)
wolf->ray->move_speed = 0.05;
if (keycode == 49)
wolf->shoot = 1;
mute_sound(keycode, wolf);
return (0);
}