-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_key_handler.c
More file actions
39 lines (36 loc) · 1.44 KB
/
ft_key_handler.c
File metadata and controls
39 lines (36 loc) · 1.44 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_key_handler.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: havyilma <havyilma@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/23 02:35:04 by havyilma #+# #+# */
/* Updated: 2023/03/25 01:21:50 by havyilma ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
int ft_key_handler(int key, t_settings *set)
{
(void)set;
ft_hook_key(key, set);
return (0);
}
void ft_hook_key(int key, t_settings *set)
{
ft_where_is_she(set, -1, -1);
if (key == 13 || key == 126)
ft_up(set);
else if (key == 1 || key == 125)
ft_down(set);
else if (key == 0 || key == 123)
ft_left(set);
else if (key == 2 || key == 124)
ft_right(set);
else if (key == 53)
ft_game_over(set);
free(set->c_move);
set->c_move = ft_itoa(set->move);
mlx_string_put(set->mlx, set->window, 64 * (set->map_width / 2), 30,
000011, set->c_move);
}