From a0bd61a8721ce5bb3ef7cf8ee675af3e190b99a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?MiraSch=C3=BCtz?= Date: Mon, 26 Oct 2026 17:48:56 +0100 Subject: [PATCH] =?UTF-8?q?game.c=20ver=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Wordsalad/game.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Wordsalad/game.c b/Wordsalad/game.c index e91de83..2e73168 100644 --- a/Wordsalad/game.c +++ b/Wordsalad/game.c @@ -14,22 +14,15 @@ // 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) { - /*srand(time(NULL)); - char bustaben[] = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"; - char zufall = bustaben[rand() % 26]; - - printf("Zufaelliger Bustabe: %c\n", zufall); - - const char words[15][MAX_WORD_LEN] = "Yeti,Nessie,Werwolf,Vampir,Monster,Hydra,Frankenstein,Dracula,KingKong,Gremlin,Kobold,Hexe,Poltergeist,Gespenst,Oge"; - - return 0; */ + int placedWords = 0; srand(time(NULL)); + for (unsigned int r=0; r < searchFieldLen; r++) { - for (int c =0; c searchFieldLen) { + continue; + } + int tries = 0; + int placed = 0; while (!placed && tries < MAX_RAND_TRIES_PER_WORD) { int direction = rand() % 2; int row; @@ -58,6 +55,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi salad[row][col +i] = words[w][i]; } placed = 1; + placedWords++; } } else { @@ -73,7 +71,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi for (int i = 0; i