Added memorybook to parsing and cleaned most of the files
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* cube3d.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: pblagoje <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/05/04 13:42:00 by pblagoje #+# #+# */
|
||||
/* Updated: 2022/05/04 13:43:02 by pblagoje ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cube3d.h"
|
||||
|
||||
void destroy_mlx(void *param)
|
||||
@@ -28,7 +40,7 @@ int shut_down(void)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
t_game *game;
|
||||
|
||||
@@ -37,23 +49,15 @@ int main(int ac, char **av)
|
||||
return (EXIT_FAILURE);
|
||||
game = init_struct();
|
||||
mb_init(destroy_mlx, game);
|
||||
|
||||
if (init_parsing(game, av[1]) && write(2, "The .cub file is invalid.\n", 26))
|
||||
if (init_parsing(game, av[1]))
|
||||
return (EXIT_FAILURE);
|
||||
|
||||
if (check_map(&(game->map)) && write(2, "The map is invalid.\n", 20))
|
||||
if (check_map(&(game->map)))
|
||||
return (EXIT_FAILURE);
|
||||
init_game(game);
|
||||
|
||||
// draw game a first time before it start
|
||||
draw(game);
|
||||
// receive a keypress event
|
||||
mlx_hook(game->win.ptr, 2, 1L << 0, keypress, game);
|
||||
// receive a keyprelease event
|
||||
mlx_hook(game->win.ptr, 3, 1L << 1, keyrelease, game);
|
||||
// receive event when clicking the red button to close the window
|
||||
mlx_hook(game->win.ptr, 17, 1L << 17, shut_down, NULL);
|
||||
// infinite loop that waits for events to occurs
|
||||
mlx_loop_hook(game->mlx_ptr, hook_action, game);
|
||||
mlx_loop(game->mlx_ptr);
|
||||
return (0);
|
||||
|
||||
Reference in New Issue
Block a user