mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
feat: close window and exit on window close event
This commit is contained in:
parent
0771881690
commit
fb4680e4bd
1 changed files with 9 additions and 2 deletions
11
src/main.c
11
src/main.c
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
|
||||
/* Updated: 2025/08/18 20:05:29 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/08/20 13:52:42 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
#include "raycast/ray.h"
|
||||
#include "sprites/sprite_caster.h"
|
||||
#include "utils/inits.h"
|
||||
#include "sprites/sprite.h"
|
||||
#include "utils/frees.h"
|
||||
#include "utils/hooks.h"
|
||||
#include "utils/inits.h"
|
||||
#include <bits/types/struct_timeval.h>
|
||||
|
|
@ -59,6 +59,12 @@ int game_loop(t_cub3d_data *data)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int good_bye(void *data)
|
||||
{
|
||||
destroy(data, 0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
t_cub3d_data data;
|
||||
|
|
@ -72,6 +78,7 @@ int main(int argc, char **argv)
|
|||
mlx_hook(data.mlx_win, KeyPress, KeyPressMask, keypress_handler, &data);
|
||||
mlx_hook(data.mlx_win, KeyRelease, KeyReleaseMask,
|
||||
keyrelease_handler, &data);
|
||||
mlx_hook(data.mlx_win, DestroyNotify, NoEventMask, good_bye, &data);
|
||||
mlx_loop_hook(data.mlx, game_loop, &data);
|
||||
mlx_loop(data.mlx);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue