clearwordsalad und fillWordsaladRand implementiert.
This commit is contained in:
parent
da8d9fc799
commit
e8f592c39b
@ -6,6 +6,7 @@
|
|||||||
#define MAX_RAND_TRIES_PER_WORD 10
|
#define MAX_RAND_TRIES_PER_WORD 10
|
||||||
#define EMPTY_CHAR 0
|
#define EMPTY_CHAR 0
|
||||||
|
|
||||||
|
//Position beinhaltet x, y und Richtung
|
||||||
//TODO: Spiellogik implementieren:
|
//TODO: Spiellogik implementieren:
|
||||||
/* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren
|
/* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren
|
||||||
* restliche Felder mit zufälligen Buchstaben füllen */
|
* restliche Felder mit zufälligen Buchstaben füllen */
|
||||||
@ -13,6 +14,10 @@
|
|||||||
// 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, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
||||||
{
|
{
|
||||||
|
Position position[1520]; //Positionsarray, 1520, weil 2 Richtungen, minimalwort größe
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,3 +26,29 @@ void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN],
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//Logik für createWordSalad: Ein Wort nach dem anderen bis entweder alle Wörter drinnen,
|
||||||
|
//Funktion dafür den gesammten Salat mit . zu befüllen.
|
||||||
|
void clearWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
|
||||||
|
{
|
||||||
|
for(unsigned int zeile = 0; zeile < searchFieldLen; zeile++)
|
||||||
|
{
|
||||||
|
for(unsigned int spalte = 0; spalte < searchFieldLen; spalte++)
|
||||||
|
{
|
||||||
|
salad[zeile][spalte] = '.'; // salad wird mit Punkten befüllt.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void fillWordsaladRand(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
|
||||||
|
{
|
||||||
|
srand(time(NULL));
|
||||||
|
for(int i = 0; i < searchFieldLen; i++)
|
||||||
|
{
|
||||||
|
for(int k = 0; k < searchFieldLen; k++)
|
||||||
|
{
|
||||||
|
if(salad[i][k] == '.')
|
||||||
|
{
|
||||||
|
salad[i][k] = 'A' + rand() % 26;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user