fixed everything

This commit is contained in:
Theo Champion 2025-06-06 13:57:31 +02:00
parent 8eb1a4962c
commit 00d0beadf1
2 changed files with 20 additions and 2 deletions

View file

@ -6,12 +6,12 @@
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */
/* Updated: 2025/05/06 13:16:18 by tchampio ### ########.fr */
/* Updated: 2025/06/06 13:12:28 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
#include "../includes/libft.h"
#include "../includes/mlx.h"
#include "../mlx/mlx.h"
#include "../includes/maputils.h"
#include <stdbool.h>
#include <unistd.h>
@ -35,6 +35,20 @@ void my_mlx_pixel_put(t_mlx_data *data, int x, int y, int color)
*(unsigned int*)dst = color;
}
int destroy(t_mapdata *map)
{
(void)map;
exit(0);
return 0;
}
int key_destroy(int keycode, t_mapdata *map)
{
if (keycode == 65307)
destroy(map);
return (0);
}
int main(int argc, char **argv)
{
void *mlx;
@ -56,6 +70,8 @@ int main(int argc, char **argv)
data.addr = mlx_get_data_addr(data.img, &data.bits_per_pixel, &data.line_length, &data.endian);
xpm_image = mlx_xpm_file_to_image(mlx, xpm, &xpm_width, &xpm_height);
//my_mlx_pixel_put(&data, 5, 5, 0x00FF0000);
mlx_hook(mlx_win, 17, 0L, destroy, &map);
mlx_key_hook(mlx_win, key_destroy, &map);
mlx_put_image_to_window(mlx, mlx_win, data.img, 0, 0);
mlx_put_image_to_window(mlx, mlx_win, xpm_image, 0, 0);
mlx_loop(mlx);