#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 */ // 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) { //Initialisiert den seed für rand() srand(time(NULL)); //Initialisiere spielfeld auf '0' // TODO: memset() for(int i = 0; i < MAX_SEARCH_FIELD_LEN; i++){ for (int j = 0; j < MAX_SEARCH_FIELD_LEN; j++){ salad[i][j] = '0'; } } int placedWords = 0; //Iterate over words unsigned int counter = 0; while(counter < wordCount){ //load current word char currentWord[MAX_WORD_LEN]; strncpy(currentWord) //try to place a word int try = 0; while(try < 10){ int x = rand() % MAX_SEARCH_FIELD_LEN; int y = rand() % MAX_SEARCH_FIELD_LEN; if (salad[x][y] == '0'){ } try++; } } return placedWords; }