init salad
This commit is contained in:
1 parent
947054bb51
commit
d368eea2f3
1 file changed
+12
-1
+12
-1
@@ -16,12 +16,21 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
//Initialisiert den seed für rand()
|
//Initialisiert den seed für rand()
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
|
//Initialisiere spielfeld auf '0'
|
||||||
|
// TODO: memset()
|
||||||
|
for(int i = 0; i < MAX_SEARCH_FIELD_LEN; i++){
|
||||||
|
for (int j = 0; j < MAX_SEARCH_FIELD_LEN; j++){
|
||||||
|
salad[i][j] = '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int placedWords = 0;
|
int placedWords = 0;
|
||||||
//Iterate over words
|
//Iterate over words
|
||||||
unsigned int counter = 0;
|
unsigned int counter = 0;
|
||||||
while(counter < wordCount){
|
while(counter < wordCount){
|
||||||
//load current word
|
//load current word
|
||||||
char currentWord[MAX_WORD_LEN] = words[counter];
|
char currentWord[MAX_WORD_LEN];
|
||||||
|
strncpy(currentWord)
|
||||||
|
|
||||||
//try to place a word
|
//try to place a word
|
||||||
int try = 0;
|
int try = 0;
|
||||||
@@ -29,7 +38,9 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
int x = rand() % MAX_SEARCH_FIELD_LEN;
|
int x = rand() % MAX_SEARCH_FIELD_LEN;
|
||||||
int y = rand() % MAX_SEARCH_FIELD_LEN;
|
int y = rand() % MAX_SEARCH_FIELD_LEN;
|
||||||
|
|
||||||
|
if (salad[x][y] == '0'){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
try++;
|
try++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user