Start_Windows/game.c aktualisiert
This commit is contained in:
parent
eaa16ed84c
commit
b60812d6c6
@ -10,6 +10,35 @@
|
|||||||
/* * 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 */
|
||||||
|
|
||||||
|
/*********************************************************************************************
|
||||||
|
|
||||||
|
// Platziert Wörter aus der Liste zufällig horizontal oder vertikal
|
||||||
|
void createWordSalad(char grid[20][20], const char words[][50], int wordCount) {
|
||||||
|
srand(time(NULL));
|
||||||
|
for (int w = 0; w < wordCount; w++) {
|
||||||
|
int len = strlen(words[w]);
|
||||||
|
int horizontal = rand() % 2;
|
||||||
|
int row = rand() % 20;
|
||||||
|
int col = rand() % 20;
|
||||||
|
|
||||||
|
if (horizontal && col + len <= 20) {
|
||||||
|
for (int i = 0; i < len; i++) grid[row][col + i] = words[w][i];
|
||||||
|
} else if (!horizontal && row + len <= 20) {
|
||||||
|
for (int i = 0; i < len; i++) grid[row + i][col] = words[w][i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Füllt alle leeren Felder mit zufälligen Buchstaben
|
||||||
|
void fillEmptySpaces(char grid[20][20]) {
|
||||||
|
for (int i = 0; i < 20; i++)
|
||||||
|
for (int j = 0; j < 20; j++)
|
||||||
|
if (grid[i][j] == 0)
|
||||||
|
grid[i][j] = 'A' + rand() % 26;
|
||||||
|
}
|
||||||
|
|
||||||
|
************************************************************************************************************/
|
||||||
|
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user