-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkey_events.c
More file actions
49 lines (46 loc) · 1.65 KB
/
key_events.c
File metadata and controls
49 lines (46 loc) · 1.65 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* key_events.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jcorral- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/27 16:56:25 by jcorral- #+# #+# */
/* Updated: 2020/03/03 10:58:46 by jcorral- ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
int deal_key(int key, t_m *params)
{
if (key == 125 || key == 1)
params->move.backward = 1;
else if (key == 126 || key == 13)
params->move.forward = 1;
else if (key == 123)
params->move.rot_left = 1;
else if (key == 124)
params->move.rot_right = 1;
else if (key == 53)
exit_game(params);
else if (key == 0)
params->move.left = 1;
else if (key == 2)
params->move.right = 1;
return (0);
}
int release_key(int key, t_m *params)
{
if (key == 125 || key == 1)
params->move.backward = 0;
else if (key == 126 || key == 13)
params->move.forward = 0;
else if (key == 123)
params->move.rot_left = 0;
else if (key == 124)
params->move.rot_right = 0;
else if (key == 0)
params->move.left = 0;
else if (key == 2)
params->move.right = 0;
return (0);
}