Compare commits

..

No commits in common. "af80d62ba6b882cf5c1f7c598687af004a95ae8e" and "5d91ffc0b101875074c7243ffa5aef8e1aef4215" have entirely different histories.

2 changed files with 5 additions and 10 deletions

View File

@ -34,22 +34,18 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
int wordlength = 0; int wordlength = 0;
do do
{ {
while((words[i][wordlength] != '\0')&&(wordlength != MAX_WORD_LEN))//gets the length of the current word while(words[i][wordlength] != '0')//gets the length of the current word
{
wordlength++; wordlength++;
} int startPosition1 = RANDOMNUMBER(0, MAX_SEARCH_FIELD_LEN - wordlength);//gets a random starting position for the word
int startPosition1 = RANDOMNUMBER(0, searchFieldLen - wordlength);//gets a random starting position for the word int startPosition2 = RANDOMNUMBER(0, MAX_SEARCH_FIELD_LEN);//gest a second coordinate for the starting position
int startPosition2 = RANDOMNUMBER(0, searchFieldLen);//gest a second coordinate for the starting position
if(RANDOMNUMBER(0,1) < 1)//Flips a coin whether the number is vertical or horizontal if(RANDOMNUMBER(0,1) < 1)//Flips a coin whether the number is vertical or horizontal
{//Horizontal {//Horizontal
int allClear = 0; int allClear = 0;
for(int j = 0; j < wordlength; j++)//Checks, if there already is a word, where the new word should be placed. for(int j = 0; j < wordlength; j++)//Checks, if there already is a word, where the new word should be placed.
{ {
if(salad[startPosition1 + j][startPosition2] != 63) if(salad[startPosition1 + j][startPosition2] != 63)
{
allClear++; allClear++;
} }
}
if(allClear == 0)//Places the word if(allClear == 0)//Places the word
{ {
for(int j = 0; j < wordlength; j++) for(int j = 0; j < wordlength; j++)

View File

@ -43,8 +43,7 @@ int main(int argc, char *argv[])
// error message if some words couldn't be placed // error message if some words couldn't be placed
int windowWidth = 720; //Fensterbreite outputfenster int windowWidth = 720; //Fensterbreite outputfenster
if (placedWords == wordCount && placedWords <= MAX_NUMBER_OF_WORDS) { if (placedWords == wordCount && placedWords <= MAX_NUMBER_OF_WORDS) {
showWordSalad(wordSalad, SALAD_SIZE); startGame(wordSalad, MAX_SEARCH_FIELD_LEN, words, wordCount, windowWidth);
startGame(wordSalad, SALAD_SIZE, words, wordCount, windowWidth);
exitCode = EXIT_SUCCESS; //Start the game if placed words is equal to words in textfile exitCode = EXIT_SUCCESS; //Start the game if placed words is equal to words in textfile
} }
else { else {