Added Method createWordSalad, but UNFINISHED

This commit is contained in:
Tobias Grampp 2025-10-30 16:32:44 +01:00
parent 5be62312c2
commit e135756db5
2 changed files with 26 additions and 3 deletions

View File

@ -7,14 +7,37 @@
#define MAX_RAND_TRIES_PER_WORD 10
#define EMPTY_CHAR 0
#define RANDOMNUMBER(minimum, maximum) rand() % (maximum minimum + 1) + minimum //Macro to generate a Number between minimum and maximum (both are possibly rolled)
//TODO: Spiellogik implementieren:
/* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren
* restliche Felder mit zufälligen Buchstaben füllen */
/* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren --> Vorher eingabe festlegen!
* restliche Felder mit zufälligen Buchstaben füllen - erldeigt*/
// 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));//sets the seed of the random function to the current time in order to guarantee unique results
for(int i = 0; i < searchFieldLen; i++)//Clears the array to simplify the process of findings empty slots
{
for(int j = 0; j < searchFieldLen; j++)
{
salad[i][j] = 63;
}
}
for(int i = 0; i < wordCount; i++)
{
}
for(int i = 0; i < searchFieldLen; i++)//Randomly fills the rest of the array
{
for(int j = 0; j < searchFieldLen; j++)
{
if((salad[i][j] == 63)//checks if there is already a letter of a word placed in here
salad[i][j] = RANDOMNUMBER(65, 90);//fills "empty" chars in word salad with a random upper case letter
}
}
}
// Prints the word salad to console