-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.c
More file actions
70 lines (64 loc) · 2.02 KB
/
Copy pathmain.c
File metadata and controls
70 lines (64 loc) · 2.02 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ataai <ataai@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/16 16:29:46 by motelti #+# #+# */
/* Updated: 2025/10/03 16:58:58 by ataai ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3D.h"
static void destroy_textures(t_game *game)
{
if (game->no_texture)
free(game->no_texture);
if (game->so_texture)
free(game->so_texture);
if (game->we_texture)
free(game->we_texture);
if (game->ea_texture)
free(game->ea_texture);
}
void handle_exit1(t_game *game)
{
int i;
i = 0;
if (game->mlx && game->win)
mlx_destroy_window(game->mlx, game->win);
if (game->map)
{
while (i < game->map_rows)
{
free(game->map[i]);
i++;
}
free(game->map);
}
destroy_textures(game);
if (game->no_img)
mlx_destroy_image(game->mlx, game->no_img);
if (game->so_img)
mlx_destroy_image(game->mlx, game->so_img);
if (game->we_img)
mlx_destroy_image(game->mlx, game->we_img);
if (game->ea_img)
mlx_destroy_image(game->mlx, game->ea_img);
exit(0);
}
int main(int argc, char **argv)
{
t_game game;
t_cube *cube;
if (init_game_data(&game, &cube, argc, argv))
return (1);
if (load_and_check_textures(&game))
return (1);
if (create_window_and_image(&game))
return (1);
mlx_loop_hook(game.mlx, render_frame, &game);
mlx_hook(game.win, 2, 1L << 0, key_press, &game);
mlx_loop(game.mlx);
return (handle_exit1(&game), 0);
}