Compare commits
1
Commits
1f5b8ad0a2
..
chris3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c30711a9c |
No files matched your search
+10
-9
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#define MAX_RAND_TRIES_PER_WORD 10
|
#define MAX_RAND_TRIES_PER_WORD 10
|
||||||
#define EMPTY_CHAR 0
|
#define EMPTY_CHAR 0
|
||||||
|
#define WORTLAENGE strlen(words[i])
|
||||||
|
|
||||||
//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
|
||||||
@@ -41,19 +42,19 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
|
|
||||||
Platzierungsrichtung zufaellige_richtung = rand() % 2;
|
Platzierungsrichtung zufaellige_richtung = rand() % 2;
|
||||||
|
|
||||||
if(zufaellige_richtung == vertikal && strlen(words[i]) <= (searchFieldLen-y))
|
if(zufaellige_richtung == vertikal && (WORTLAENGE <= (searchFieldLen-y)))
|
||||||
{
|
{
|
||||||
int check = 0;
|
int check = 0;
|
||||||
for(int k = 0; k < strlen(words[i]); k++)
|
for(int k = 0; k < WORTLAENGE; k++)
|
||||||
{
|
{
|
||||||
if(salad[y+k][x] == '0' || salad[y+k][x] == words[i][k])
|
if(salad[y+k][x] == '0' || salad[y+k][x] == words[i][k])
|
||||||
{
|
{
|
||||||
check ++;
|
check ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(check == strlen(words[i]))
|
if(check == WORTLAENGE)
|
||||||
{
|
{
|
||||||
for(int j = 0; j < strlen(words[i]); j++)
|
for(int j = 0; j < WORTLAENGE; j++)
|
||||||
{
|
{
|
||||||
salad[y+j][x] = words[i][j];
|
salad[y+j][x] = words[i][j];
|
||||||
}
|
}
|
||||||
@@ -62,10 +63,10 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if( zufaellige_richtung == horizontal && strlen(words[i]) <= (searchFieldLen-x))
|
else if( zufaellige_richtung == horizontal && WORTLAENGE <= (searchFieldLen-x))
|
||||||
{
|
{
|
||||||
int check = 0;
|
int check = 0;
|
||||||
for(int k = 0; k < strlen(words[i]); k++)
|
for(int k = 0; k < WORTLAENGE; k++)
|
||||||
{
|
{
|
||||||
if(salad[y][x+k] == '0' || salad[y][x+k] == words[i][k])
|
if(salad[y][x+k] == '0' || salad[y][x+k] == words[i][k])
|
||||||
{
|
{
|
||||||
@@ -73,9 +74,9 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(check == strlen(words[i]))
|
if(check == WORTLAENGE)
|
||||||
{
|
{
|
||||||
for(int j = 0; j < strlen(words[i]); j++)
|
for(int j = 0; j < WORTLAENGE; j++)
|
||||||
{
|
{
|
||||||
|
|
||||||
salad[y][x+j] = words[i][j];
|
salad[y][x+j] = words[i][j];
|
||||||
@@ -93,7 +94,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
{
|
{
|
||||||
if(salad[i][j] == '0')
|
if(salad[i][j] == '0')
|
||||||
{
|
{
|
||||||
salad[i][j] = rand() % (90-65+1)+ 65;
|
salad[i][j] = rand() % (90-65+1)+ 65; //Großbuchstaben
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
strncpy(words[wordCount], token, MAX_WORD_LEN -1); //speichert einzelnes Wort in das gegeben word array ab und holt sich das nächste im Puffer, bis array leer token == NULL
|
strncpy(words[wordCount], token, MAX_WORD_LEN -1); //speichert einzelnes Wort in das gegeben word array ab und holt sich das nächste im Puffer, bis array leer token == NULL
|
||||||
//words[wordCount][MAX_WORD_LEN - 1] = '\0';
|
|
||||||
|
|
||||||
wordCount++;
|
wordCount++;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user