-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhook_bonus.c
More file actions
48 lines (44 loc) · 1.76 KB
/
hook_bonus.c
File metadata and controls
48 lines (44 loc) · 1.76 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* hook_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kalshaer <kalshaer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/23 13:54:36 by kalshaer #+# #+# */
/* Updated: 2023/03/30 10:49:20 by kalshaer ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long_bonus.h"
int close_window(t_mlx *mlx)
{
mlx_destroy_image(mlx->mlx, mlx->p.img);
mlx_destroy_image(mlx->mlx, mlx->w.img);
mlx_destroy_image(mlx->mlx, mlx->s.img);
mlx_destroy_image(mlx->mlx, mlx->c.img);
mlx_destroy_image(mlx->mlx, mlx->e.img);
mlx_destroy_image(mlx->mlx, mlx->sh.img);
mlx_destroy_window(mlx->mlx, mlx->win);
free_s(mlx->map);
exit (0);
}
int hooking_function(int key, t_mlx *mlx)
{
static int moves;
char *s;
if (key == 53)
destory(NULL, mlx, 1);
else if (key == 13 || key == 126)
move_up(mlx, &moves);
else if (key == 2 || key == 124)
move_right(mlx, &moves);
else if (key == 1 || key == 125)
move_down(mlx, &moves);
else if (key == 0 || key == 123)
move_left(mlx, &moves);
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->w.img, 0, 0);
s = ft_itoa(moves);
mlx_string_put(mlx->mlx, mlx->win, 0, 10, 0x00000000, s);
free(s);
return (0);
}