From c506575b0dd3c52587c379595b312ce3d5ef8c91 Mon Sep 17 00:00:00 2001 From: KRUGSON Date: Sun, 5 Feb 2023 03:17:00 +0100 Subject: [PATCH] added function processInput and exit of game --- src/c/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/c/main.c b/src/c/main.c index ecf1c18..ecaa444 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -13,6 +13,7 @@ char *gameInstructionsFile = "../../src/content/game_instructions.txt"; // function declarations void printInit(); void acceptInstructions(); +void processInput(); int main() { @@ -34,7 +35,7 @@ int main() // NEXT STEP: // Processing - // processInput(userInput); + processInput(userInput); } } return 0; @@ -93,4 +94,18 @@ void acceptInstructions() printf("Invalid Input!\n"); } } +} + +//process user input +void processInput(char userInput[20]) +{ + if (strcmp(userInput, "esc") == 0 || strcmp(userInput, "exit") == 0 || strcmp(userInput, "quit") == 0) + { + gameRunning = 0; + printf("!GAME EXIT!\n"); + } + else + { + printf("Wrong Input!\n"); + } } \ No newline at end of file