#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) { srand(time(NULL)); int wortrest = wordCount; int akt_word; int lage; int pos_x; int pos_y; int belegt = 2; int belegt_counter; int fehlende_woerter=0; int startwechsel = 0; char demostring[searchFieldLen]; char vergleichstring[searchFieldLen]; //salad befuellen mit "0" for (int i=0;i0){ belegt_counter = MAX_RAND_TRIES_PER_WORD; while (belegt_counter > 0){ akt_word = (wordCount-wortrest); if(belegt_counter<(MAX_RAND_TRIES_PER_WORD/2)){ } //horizontal/vertikal lage = rand()%2; switch (lage){ case 0://Waagerecht pos_x = rand()%(searchFieldLen-strlen(words[akt_word])); pos_y = rand()%(searchFieldLen); for (int leange_counter = 0;leange_counter