Update game.c
This commit is contained in:
1 parent
93db739464
commit
947054bb51
1 file changed
+21
@@ -13,5 +13,26 @@
|
||||
// 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)
|
||||
{
|
||||
//Initialisiert den seed für rand()
|
||||
srand(time(NULL));
|
||||
|
||||
int placedWords = 0;
|
||||
//Iterate over words
|
||||
unsigned int counter = 0;
|
||||
while(counter < wordCount){
|
||||
//load current word
|
||||
char currentWord[MAX_WORD_LEN] = words[counter];
|
||||
|
||||
//try to place a word
|
||||
int try = 0;
|
||||
while(try < 10){
|
||||
int x = rand() % MAX_SEARCH_FIELD_LEN;
|
||||
int y = rand() % MAX_SEARCH_FIELD_LEN;
|
||||
|
||||
|
||||
|
||||
try++;
|
||||
}
|
||||
}
|
||||
return placedWords;
|
||||
}
|
||||
Reference in new issue
Block a user