summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..82c28e6
--- /dev/null
+++ b/main.c
@@ -0,0 +1,51 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* main.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: kdx <kdx @student.42angouleme.fr +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2022/10/07 01:51:52 by kdx #+# #+# */
+/* Updated: 2022/10/14 14:45:59 by kdx ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "badeline.h"
+#include "libft/libft.h"
+#include "game.h"
+#include "sily.h"
+#include "sprite.h"
+#include "player.h"
+#include <stdlib.h>
+
+static void update(t_sily *sily)
+{
+ sily_input_update(sily);
+ player_update(sily, &sily->game->player);
+ badeline_update(&sily->game->badeline);
+ if (sily->game->victory)
+ {
+ ft_putendl_fd("Victory!", 1);
+ game_destroy(sily->game);
+ exit(0);
+ }
+}
+
+static void draw(t_sily *sily)
+{
+ game_draw(sily->game);
+}
+
+int main(int argc, char **argv)
+{
+ t_game *game;
+
+ if (argc != 2)
+ return (ft_printf("Error\nusage: so_long <map.ber>\n"));
+ game = game_new(argv[1]);
+ if (game == NULL)
+ return (1);
+ game->redraw = 1;
+ sily_loop(game->sily, update, draw);
+ return (0);
+}