diff --git a/Start_Windows/game.c b/Start_Windows/game.c index 3f40b9b..f7fa67d 100644 --- a/Start_Windows/game.c +++ b/Start_Windows/game.c @@ -107,22 +107,26 @@ int checkIfPositionIsFree(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN] int placeWord(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], wordPosition position, const char currentWord[], unsigned int currentWordLen, unsigned int serchFieldLen) { int i = 0; + int j = 0; if (position.alignment == HORIZONTAL) { - - for (i = position.startingCell; (i < serchFieldLen) && (i < currentWordLen); i++) + for (i = position.startingCell; (i < serchFieldLen) || (j < currentWordLen); i++) { - salad[position.rowOrColumn][i] = currentWord[i]; + salad[position.rowOrColumn][i] = currentWord[j]; + printf("%c",currentWord[j]); + j++; } salad[position.rowOrColumn][i] = '\0'; } else if (position.alignment == VERTIKAL) { - for (i = position.startingCell; (i < serchFieldLen) && (i < currentWordLen); i++) + for (i = position.startingCell; (i < serchFieldLen) || (j < currentWordLen); i++) { - salad[i][position.rowOrColumn] = currentWord[i]; + salad[i][position.rowOrColumn] = currentWord[j]; + printf("%c",currentWord[j]); + j++; } salad[i][position.rowOrColumn] = '\0'; } @@ -165,6 +169,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi srand(time(NULL)); initializeWordsalad(salad, searchFieldLen); + showWordSalad(salad, searchFieldLen); for (i = 1; i <= wordCount; i++) { @@ -178,7 +183,11 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi if (positionFound) { + strcpy(currentWord, "\0"); strcpy(currentWord, words[i-1]); + + printf("%d, %d, %d \n", currentWordPosition.alignment, currentWordPosition.rowOrColumn, currentWordPosition.startingCell); + printf("%s\n", currentWord); placedWords += placeWord(salad, currentWordPosition, currentWord, strlen(currentWord), searchFieldLen); } } diff --git a/Start_Windows/game.o b/Start_Windows/game.o index 1b664f5..b2fada6 100644 Binary files a/Start_Windows/game.o and b/Start_Windows/game.o differ