#include "game.h" #include #include #include #define MAX_RAND_TRIES_PER_WORD 10 #define EMPTY_CHAR 0 //TODO: Spiellogik implementieren: /* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren * restliche Felder mit zufälligen Buchstaben füllen */ // Platziert Wörter aus der Liste zufällig horizontal oder vertikal void createWordSalad(char grid[20][20], const char words[][50], int wordCount) { srand(time(NULL)); for (int w = 0; w < wordCount; w++) { int len = strlen(words[w]); int horizontal = rand() % 2; int row = rand() % 20; int col = rand() % 20; if (horizontal && col + len <= 20) { for (int i = 0; i < len; i++) grid[row][col + i] = words[w][i]; } else if (!horizontal && row + len <= 20) { for (int i = 0; i < len; i++) grid[row + i][col] = words[w][i]; } } } // Füllt alle leeren Felder mit zufälligen Buchstaben void fillEmptySpaces(char grid[20][20]) { for (int i = 0; i < 20; i++) for (int j = 0; j < 20; j++) if (grid[i][j] == 0) grid[i][j] = 'A' + rand() % 26; } // 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) { } // Prints the word salad to console void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen) { }