3 Commits
Author SHA1 Message Date
wiesendsi102436 9b6699b543 seed random number 2025-11-07 08:02:30 +01:00
wiesendsi102436 e3e5d4d434 no magic numbers 2025-11-06 19:40:15 +01:00
wiesendsi102436 97ed155236 adapt gui to missing words 2025-11-06 19:37:13 +01:00
4 changed files with 8 additions and 2 deletions
+2
View File
@@ -13,6 +13,8 @@
// Creates the word salad by placing words randomly and filling empty spaces // 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, char words[][MAX_WORD_LEN], unsigned int wordCount) int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, char words[][MAX_WORD_LEN], unsigned int wordCount)
{ {
srand(time(NULL));
int row, col, placedWords = 0; int row, col, placedWords = 0;
// Gesamtes Feld auf 0 setzen // Gesamtes Feld auf 0 setzen
+2 -1
View File
@@ -6,6 +6,7 @@
#define MAX_NUMBER_OF_WORDS 100 #define MAX_NUMBER_OF_WORDS 100
#define SALAD_SIZE 20 #define SALAD_SIZE 20
#define WINDOW_WIDTH 800
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@@ -47,7 +48,7 @@ int main(int argc, char *argv[])
// Start game if at least 1 word was successfully placed // Start game if at least 1 word was successfully placed
if (placedWords > 0) if (placedWords > 0)
{ {
startGame(wordSalad, SALAD_SIZE, words, wordCount, 800); startGame(wordSalad, SALAD_SIZE, words, placedWords, WINDOW_WIDTH);
} }
else else
{ {
+2
View File
@@ -13,6 +13,8 @@
// Creates the word salad by placing words randomly and filling empty spaces // 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, char words[][MAX_WORD_LEN], unsigned int wordCount) int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, char words[][MAX_WORD_LEN], unsigned int wordCount)
{ {
srand(time(NULL));
int row, col, placedWords = 0; int row, col, placedWords = 0;
// Gesamtes Feld auf 0 setzen // Gesamtes Feld auf 0 setzen
+2 -1
View File
@@ -6,6 +6,7 @@
#define MAX_NUMBER_OF_WORDS 100 #define MAX_NUMBER_OF_WORDS 100
#define SALAD_SIZE 20 #define SALAD_SIZE 20
#define WINDOW_WIDTH 800
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@@ -47,7 +48,7 @@ int main(int argc, char *argv[])
// Start game if at least 1 word was successfully placed // Start game if at least 1 word was successfully placed
if (placedWords > 0) if (placedWords > 0)
{ {
startGame(wordSalad, SALAD_SIZE, words, wordCount, 800); startGame(wordSalad, SALAD_SIZE, words, placedWords, WINDOW_WIDTH);
} }
else else
{ {