game.c
This commit is contained in:
1 parent
e931591801
commit
d21c6beda0
1 file changed
+42
@@ -13,5 +13,47 @@
|
||||
// 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 i,j;
|
||||
int Woertergesetzt = 0;
|
||||
for (i=0 ; i<MAX_SEARCH_FIELD_LEN;i++);
|
||||
{
|
||||
for (j=0 ; j<MAX_SEARCH_FIELD_LEN;j++);
|
||||
{
|
||||
salad[i][j] = 0;
|
||||
}
|
||||
}
|
||||
for (int k = 0 ; k < wordCount ; k++);
|
||||
{
|
||||
int richtigplatziert = 0;
|
||||
for (int f = 0 ; f < 1000 && !richtigplatziert ; f++);
|
||||
{
|
||||
int ausrichtung, zeile, spalte;
|
||||
ausrichtung = rand() % 2;
|
||||
zeile = rand() % (searchFieldLen);
|
||||
spalte = rand() % (searchFieldLen);
|
||||
|
||||
if (ausrichtung == 0);
|
||||
{
|
||||
if ((spalte + strlen)(words[k]) < MAX_SEARCH_FIELD_LEN);
|
||||
{
|
||||
int moeglichePosition = 1;
|
||||
for (int i1 = 0; i1< strlen(words[k]); i1++);
|
||||
{
|
||||
if (salad[zeile][spalte + i] !=0);
|
||||
moeglichePosition = 0;
|
||||
}
|
||||
richtigplatziert = 1;
|
||||
Woertergesetzt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((zeile + strlen(words[k]));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user