glaube jetzt alles gefixed zu haben
This commit is contained in:
1 parent
029eb426ab
commit
28c70cf01b
1 file changed
+6
-8
+6
-8
@@ -29,8 +29,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
|
|
||||||
int placedWords = 0;
|
int placedWords = 0;
|
||||||
//Iterate over words
|
//Iterate over words
|
||||||
unsigned int counter = 0;
|
for(int counter = 0; counter < wordCount; counter++){
|
||||||
while(counter < wordCount){
|
|
||||||
|
|
||||||
size_t len = strlen(words[counter]);
|
size_t len = strlen(words[counter]);
|
||||||
//try to place a word
|
//try to place a word
|
||||||
@@ -41,8 +40,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
|
|
||||||
int dir = rand() % 2;
|
int dir = rand() % 2;
|
||||||
|
|
||||||
if ((MAX_SEARCH_FIELD_LEN - x) < len){
|
if ((MAX_SEARCH_FIELD_LEN - x - 1) < len){
|
||||||
if((MAX_SEARCH_FIELD_LEN - y) < len){
|
if((MAX_SEARCH_FIELD_LEN - y - 1) < len){
|
||||||
// cant place word here (too far in the bottom right corner)
|
// cant place word here (too far in the bottom right corner)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -65,11 +64,9 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
salad[x][y+i] = words[counter][i];
|
salad[x][y+i] = words[counter][i];
|
||||||
}
|
}
|
||||||
placedWords++;
|
placedWords++;
|
||||||
counter++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}else{
|
||||||
//place currentWord horizontally
|
//place currentWord horizontally
|
||||||
|
|
||||||
//see if all neccessary spaces are emtry
|
//see if all neccessary spaces are emtry
|
||||||
bool cont = false;
|
bool cont = false;
|
||||||
for (int i = 0; i < (int)len; i++){
|
for (int i = 0; i < (int)len; i++){
|
||||||
@@ -87,7 +84,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
salad[x+1][y] = words[counter][i];
|
salad[x+1][y] = words[counter][i];
|
||||||
}
|
}
|
||||||
placedWords++;
|
placedWords++;
|
||||||
counter++;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < MAX_SEARCH_FIELD_LEN; i++){
|
for (int i = 0; i < MAX_SEARCH_FIELD_LEN; i++){
|
||||||
|
|||||||
Reference in new issue
Block a user