fertig game.c

This commit is contained in:
roesselid103915 committed 2026-10-26 08:07:43 +01:00
1 parent f1fdbb5424
commit 88575ba8bf
1 file changed
+6 -14
+6 -14
View File
@@ -11,12 +11,9 @@
/* * 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 */
int clearField();
int placeWords();
// 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) {
{
/*srand(time(NULL)); /*srand(time(NULL));
char bustaben[] = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"; char bustaben[] = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
char zufall = bustaben[rand() % 26]; char zufall = bustaben[rand() % 26];
@@ -31,21 +28,12 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
srand(time(NULL)); srand(time(NULL));
clearField[ROWS, COLS];
placeWords();
return 0;
}
int clearField() {
for (int r=0; r < ROWS; r++) { for (int r=0; r < ROWS; r++) {
for (int c =0; c < COLS; c++) { for (int c =0; c < COLS; c++) {
grid[r][c] = '.'; grid[r][c] = '.';
} }
} }
}
int placeWords() {
//Wörter plazieren //Wörter plazieren
for (unsigned int w = 0; w< wordCount; w++) { for (unsigned int w = 0; w< wordCount; w++) {
int wordLen = strlen(words[w]); int wordLen = strlen(words[w]);
@@ -86,7 +74,7 @@ int placeWords() {
} }
} }
} }
}
//Rest mit Zufallszahlen füllen //Rest mit Zufallszahlen füllen
for (int r=0; r < ROWS; r++) { for (int r=0; r < ROWS; r++) {
for (int c=0; c < COLS; c++) { for (int c=0; c < COLS; c++) {
@@ -95,4 +83,8 @@ int placeWords() {
} }
} }
} }
}
return 0;
} }