diff --git a/Start_Windows/game.c b/Start_Windows/game.c index dab22bf..95ad8ab 100644 --- a/Start_Windows/game.c +++ b/Start_Windows/game.c @@ -15,15 +15,15 @@ // 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 addedWords = 0; - int attempts = 0; //Anzahl an Versuchen ein Wort hinzuzufügen - int added = 0; //0 Wort nicht hinzugefügt , 1 Wort hinzugefügt - int space = 0; // 1 = Wort zu lang für diese Stelle + int attempts = 0; + int added = 0; // = 1 wäre Wort hinzugefügt + int space = 0; // = 1 wäre Wort zu lang für diese Stelle unsigned long long wordLength = 0; srand(time(NULL)); for (int i = 0; i < searchFieldLen; i++) { for (int j = 0; j < searchFieldLen; j++) { - salad[i][j] = '.'; //Füllen des gesamten Arrays mit Nullen + salad[i][j] = '.'; //Füllen des gesamten Arrays mit '.' } } for (int i=0; i < wordCount; i++) @@ -32,30 +32,31 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi wordLength = strlen(words[i]); while (attempts <= MAX_RAND_TRIES_PER_WORD && added != 1) { - int direction = rand() % 2;// 0 Horizontal, 1 Vertikal - if (direction == 0) { + int direction = rand() % 2;// 0 = Horizontal, 1 = Vertikal + if (direction == 0) //Horizontal + { int spalte = rand() % searchFieldLen; int reihe = rand() % searchFieldLen; for (int j = 0; j < wordLength; j++) { - if (salad[reihe][spalte+j] != '.') //Prüfen ob das Wort ein bereits vorhandenes Wort überspeichern würde + if (salad[reihe][spalte+j] != '.') //Prüfen das Wort mit einem anderem Wort überlappen würde { space = 1; break; } } - if ((spalte + wordLength >= searchFieldLen-1) || (space == 1)) + if ((spalte + wordLength >= searchFieldLen-1) || (space == 1)) // überprüfung, ob das Wort an der Stelle ins Array passt { attempts++; } - //Prüfen ob Wort an der Stelle (Zeile, Spalte) in das Array passt + else { for (int j = 0; j < wordLength; j++) { - salad[reihe][spalte+j] = words[i][j]; //Einfügen des Wortes Buchstabe für Buchstabe + salad[reihe][spalte+j] = words[i][j]; //Einfügen er Chars des Wortes } added=1; addedWords++; @@ -99,7 +100,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi for (int j = 0; j < searchFieldLen; j++) { if (salad[i][j] == '.') { - salad[i][j] = rand()%('Z'-'A'+1)+'A';//Alle Felder, die noch nicht befüllt sind, werden zufällig befüllt + salad[i][j] = rand()%('Z'-'A'+1)+'A';//Zufällige Befüllung der noch nicht befüllten Felder } } } diff --git a/Start_Windows/game.o b/Start_Windows/game.o new file mode 100644 index 0000000..00f1b4d Binary files /dev/null and b/Start_Windows/game.o differ diff --git a/Start_Windows/graphicalGame.o b/Start_Windows/graphicalGame.o new file mode 100644 index 0000000..b70ae22 Binary files /dev/null and b/Start_Windows/graphicalGame.o differ diff --git a/Start_Windows/wordsalad.exe b/Start_Windows/wordsalad.exe new file mode 100644 index 0000000..7c62989 Binary files /dev/null and b/Start_Windows/wordsalad.exe differ