-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkey_identification.c
More file actions
80 lines (76 loc) · 1.9 KB
/
Copy pathkey_identification.c
File metadata and controls
80 lines (76 loc) · 1.9 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
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* key_identification.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbertin <mbertin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/31 15:55:30 by mbertin #+# #+# */
/* Updated: 2022/09/06 08:42:44 by mbertin ### ########.fr */
/* */
/* ************************************************************************** */
#include "include/so_long.h"
int key_identification(int key, t_map *map)
{
if (key == 53)
{
printf("You press esc to exit the game ! Go back to work ...\n");
exit (1);
mlx_destroy_window(map->mlx, map->win);
}
if (key == 2)
{
map->i = 0;
while (map->i < map->x - 1)
{
check_right(map);
map->i++;
map->j = 0;
}
check_right_villain(map);
}
key_identification_part_two(key, map);
return (0);
}
int key_identification_part_two(int key, t_map *map)
{
if (key == 0)
{
map->i = 0;
while (map->i < map->x - 1)
{
check_left(map);
map->i++;
map->j = 0;
}
check_left_villain(map);
}
if (key == 13)
{
map->i = 0;
while (map->i < map->x - 1)
{
check_up(map);
map->i++;
map->j = 0;
}
check_up_villain(map);
}
key_identification_part_three(key, map);
return (0);
}
int key_identification_part_three(int key, t_map *map)
{
if (key == 1)
{
map->i = 0;
while (map->i < map->x - 1)
{
check_down(map);
map->i++;
map->j = 0;
}
check_down_villain(map);
}
return (0);
}