-
Notifications
You must be signed in to change notification settings - Fork 0
/
key.c
executable file
·44 lines (40 loc) · 1.42 KB
/
key.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* key.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jchapell <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/09 03:37:31 by jchapell #+# #+# */
/* Updated: 2023/06/01 05:03:54 by jchapell ### ########.fr */
/* */
/* ************************************************************************** */
#include "inc/proto.h"
int key_press(int keycode, t_level *lvl)
{
if (keycode == 53 || keycode == 65307)
clean_exit(lvl);
if (!lvl->key[int_to_dir(keycode)])
{
lvl->key[int_to_dir(keycode)] = 1;
if (lvl->name)
{
lvl->player.move++;
print_move(lvl->player.move);
}
}
return (0);
}
int key_release(int keycode, t_level *lvl)
{
if (lvl->key[int_to_dir(keycode)])
lvl->key[int_to_dir(keycode)] = 0;
return (0);
}
int clean_exit(t_level *l)
{
info("Clean exit");
if (l->data.coins_max != -1)
free_level(l);
exit(info("Game closed"));
}