forked from freudenreichan/info2Praktikum-Wortsalat
fertig game.c
This commit is contained in:
1 parent
f1fdbb5424
commit
88575ba8bf
1 file changed
+12
-20
+12
-20
@@ -11,12 +11,9 @@
|
||||
/* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren
|
||||
* restliche Felder mit zufälligen Buchstaben füllen */
|
||||
|
||||
int clearField();
|
||||
int placeWords();
|
||||
|
||||
// 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));
|
||||
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];
|
||||
@@ -31,21 +28,12 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
clearField[ROWS, COLS];
|
||||
placeWords();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int clearField() {
|
||||
for (int r=0; r < ROWS; r++) {
|
||||
for (int c =0; c < COLS; c++) {
|
||||
grid[r][c] = '.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int placeWords() {
|
||||
//Wörter plazieren
|
||||
for (unsigned int w = 0; w< wordCount; w++) {
|
||||
int wordLen = strlen(words[w]);
|
||||
@@ -86,13 +74,17 @@ int placeWords() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Rest mit Zufallszahlen füllen
|
||||
for (int r=0; r < ROWS; r++) {
|
||||
for (int c=0; c < COLS; c++) {
|
||||
if (grid[r][c] == '.') {
|
||||
grid[r][c]='A' + rand() % 26;
|
||||
|
||||
//Rest mit Zufallszahlen füllen
|
||||
for (int r=0; r < ROWS; r++) {
|
||||
for (int c=0; c < COLS; c++) {
|
||||
if (grid[r][c] == '.') {
|
||||
grid[r][c]='A' + rand() % 26;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user