-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbinding.c
70 lines (64 loc) · 1.89 KB
/
binding.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* binding.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ahamdaou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/14 01:54:12 by ahamdaou #+# #+# */
/* Updated: 2021/01/22 18:53:53 by ahamdaou ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void global_binding(int key)
{
if (key == KEY_ESC)
game_exit(0);
}
void minimap_binding(int key)
{
if (key == KEY_M)
{
if (g_pref.is_minimap_enabled == FALSE)
g_pref.is_minimap_enabled = TRUE;
else
g_pref.is_minimap_enabled = FALSE;
}
}
void movement_binding(int key)
{
if (key == KEY_W)
{
g_player.walk_direction = 1;
g_player.move_forward_or_backward = TRUE;
}
else if (key == KEY_A)
g_player.left = TRUE;
else if (key == KEY_S)
{
g_player.walk_direction = -1;
g_player.move_forward_or_backward = TRUE;
}
else if (key == KEY_D)
g_player.right = TRUE;
}
void rotation_binding(int key)
{
if (key == KEY_LEFT_ARROW)
g_player.turn_direction = -1;
if (key == KEY_RIGHT_ARROW)
g_player.turn_direction = 1;
}
void minimap_resezing_binding(int key)
{
if (key == KEY_P)
{
if (!(g_game.map_width * g_game.minimap_scale > g_game.win_width))
g_game.minimap_scale += 0.01;
}
else if (key == KEY_O)
{
if (!(g_game.minimap_scale < 0.1))
g_game.minimap_scale -= 0.01;
}
}