From 19ce7c7cf96edb0e9e262e06f317551edf774a0f Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 25 Oct 2026 20:37:16 +0100 Subject: [PATCH] Game.c gebaut, noch nicht getestet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Game.c erweitert, Wörter werden platziert, leere Felder mit random Buchstaben aufgefüllt. Kontrollfunktion in Arbeit --- Wortsalat_CLion/Startcode/game.c | 76 ++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Wortsalat_CLion/Startcode/game.c diff --git a/Wortsalat_CLion/Startcode/game.c b/Wortsalat_CLion/Startcode/game.c new file mode 100644 index 0000000..e362445 --- /dev/null +++ b/Wortsalat_CLion/Startcode/game.c @@ -0,0 +1,76 @@ +#include "game.h" +#include +#include +#include + +#define MAX_RAND_TRIES_PER_WORD 10 +#define EMPTY_CHAR 0 + +//TODO: Spiellogik implementieren: +/* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren + * restliche Felder mit zufälligen Buchstaben füllen */ + +// Creates the word salad by placing words randomly and filling empty spaces +int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount, int control[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]) +{ + int row, col, word, startcol=0, startrow=0; + srand(time(NULL)); + for(row=0; row