-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_utils.c
81 lines (75 loc) · 2.08 KB
/
event_utils.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
76
77
78
79
80
81
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* event_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hgrissen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/15 16:10:45 by hgrissen #+# #+# */
/* Updated: 2021/02/15 16:47:34 by hgrissen ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void arrow_p_events(int keycode)
{
if (keycode == L_ARR)
g_p.turndir = -1;
if (keycode == R_ARR)
g_p.turndir = 1;
}
void wasd_p_events(int keycode)
{
if (keycode == A_KEY)
{
g_p.hlfpi = -M_PI_2;
g_p.vir_dir = 1;
}
if (keycode == D_KEY)
{
g_p.hlfpi = M_PI_2;
g_p.vir_dir = 1;
}
if (keycode == S_KEY)
g_p.vir_dir = -1;
if (keycode == W_KEY)
g_p.vir_dir = 1;
}
void arrow_r_events(int keycode)
{
if (keycode == L_ARR)
g_p.turndir = 0;
if (keycode == R_ARR)
g_p.turndir = 0;
}
void wasd_r_events(int keycode)
{
if (keycode == A_KEY)
{
g_p.hlfpi = 0;
g_p.vir_dir = 0;
}
if (keycode == D_KEY)
{
g_p.hlfpi = 0;
g_p.vir_dir = 0;
}
if (keycode == S_KEY)
g_p.vir_dir = 0;
if (keycode == W_KEY)
g_p.vir_dir = 0;
}
void bonus_events(int keycode, int pr)
{
if (keycode == SPACE && BON == 1 && g_p.crouch < 100 + CROUCH && !pr)
g_p.iscrouch = 0;
if (keycode == SPACE && BON == 1 && g_p.crouch < 100 && pr)
g_p.iscrouch = 1;
if (keycode == D_ARR && g_p.crouch < 280 && BON && pr)
g_p.crouch += 20;
if (keycode == U_ARR && g_p.crouch > -280 && BON && pr)
g_p.crouch -= 20;
if (keycode == TAB && pr)
g_p.ismap = 1;
if (keycode == TAB && !pr)
g_p.ismap = 0;
}