generated from freudenreichan/info2Praktikum-Wortsalat
zufallsgenerator in game.c
This commit is contained in:
parent
83b8ac3e87
commit
5cb8db0a16
@ -13,7 +13,29 @@
|
|||||||
// Creates the word salad by placing words randomly and filling empty spaces
|
// 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 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));
|
||||||
|
|
||||||
|
for (int i = 0;i < searchFieldLen; i++) { //Feld mit random Buchstaben füllen
|
||||||
|
for (int j = 0; j < searchFieldLen; j++) {
|
||||||
|
salad[i][j] = 'A' + (rand() % 26);
|
||||||
|
}
|
||||||
|
salad[i][j] = 'A' + (rand() % 26);
|
||||||
|
}
|
||||||
|
|
||||||
|
wordCount = sizeof(words) / sizeof(words[0]); //Array das mit der Anzahl der Wörter gefüllt wird
|
||||||
|
int wordOrientation[wordCount];
|
||||||
|
|
||||||
|
for (int w = 0;w < wordCount; w++) { //Randomizer, ob Wort horizontal oder vertikal wird
|
||||||
|
wordOrientation[w] = rand() % 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//for (int w = 0,w < wordCount, w++) {
|
||||||
|
// const char *words = words[w];
|
||||||
|
//int wordlen = strlen (words);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints the word salad to console
|
// Prints the word salad to console
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user