From a7a9947fe3d5d202b0389c17f0af1f0ff05a5c2e Mon Sep 17 00:00:00 2001 From: Efe ERKEN <efe.erken@etu.unistra.fr> Date: Sat, 19 Nov 2022 13:37:05 +0100 Subject: [PATCH] :sparkles: NEW: Add core game functionality The game is at a working state with a CLI --- src/main.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 196ccb5..774c22b 100644 --- a/src/main.c +++ b/src/main.c @@ -1,20 +1,36 @@ #include <stdio.h> +#include <stdlib.h> #include <stdbool.h> #include "grid.h" +#include "player.h" -int main(void) +int main() { + grid *level = init_level("levels/level1.txt"); + char entry = '\0'; bool run = true; while (run) { - char entry = fgetc(stdin); + printf("\nAppuyez sur \"q\" pour quitter\n"); + printf("Appuyez sur \"h, j, k, l\" pour vous déplacer\n\n"); + display(level); + printf("Votre choix : "); + scanf(" %c", &entry); switch (entry) { case 'q': - { run = false; break; - } + case 'h': + case 'j': + case 'k': + case 'l': + move_player(level, entry); + break; + default: + printf("---> Cette touche n'a pas de fonctionnalité\n"); } } + free_level(level); + return EXIT_SUCCESS; } -- GitLab