finales Programm

This commit is contained in:
fischerch103508 committed 2026-10-23 10:24:40 +02:00
1 parent 1f5b8ad0a2
commit 1c30711a9c
2 files changed
+10 -10

No files matched your search

+10 -9
View File
@@ -5,6 +5,7 @@
#define MAX_RAND_TRIES_PER_WORD 10
#define EMPTY_CHAR 0
#define WORTLAENGE strlen(words[i])
//TODO: Spiellogik implementieren:
/* * 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;
if(zufaellige_richtung == vertikal && strlen(words[i]) <= (searchFieldLen-y))
if(zufaellige_richtung == vertikal && (WORTLAENGE <= (searchFieldLen-y)))
{
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])
{
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];
}
@@ -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;
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])
{
@@ -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];
@@ -93,7 +94,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
{
if(salad[i][j] == '0')
{
salad[i][j] = rand() % (90-65+1)+ 65;
salad[i][j] = rand() % (90-65+1)+ 65; //Großbuchstaben
}
}
}
-1
View File
@@ -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
//words[wordCount][MAX_WORD_LEN - 1] = '\0';
wordCount++;