Compare commits

..
8 Commits
Author SHA1 Message Date
kesidisgi101215 28ad7982e8 merge upstream 2025-10-28 13:42:39 +00:00
Giorgi Kesidis c2166d2314 makefile change 2025-10-28 13:41:24 +01:00
freudenreichan eaa16ed84c Module fehlerhaft übersetzt. 2025-10-28 09:18:39 +00:00
Giorgi Kesidis 00ddc2b389 srand für bessere zufallszahlen 2025-10-27 20:39:19 +01:00
Giorgi Kesidis 6f1a59af0c Fix gross klein 2025-10-27 20:35:05 +01:00
Giorgi Kesidis 63b1ccd0ea fix vom 27.10 2025-10-27 20:07:40 +01:00
Giorgi Kesidis 1e229ad916 27.10 Änderung 2 2025-10-27 19:50:18 +01:00
Giorgi Kesidis a1930fa74e 27.10 änderung nach test 2025-10-27 19:45:25 +01:00
12 changed files with 23 additions and 13 deletions
Binary file not shown.
+12 -13
View File
@@ -13,29 +13,29 @@
// 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)
{
srand(time(NULL));
// wipe field
int placedWords = 0;
for (int i = 0; searchFieldLen < i; i++)
for (int i = 0; i < searchFieldLen; i++)
{
for (int j = 0; searchFieldLen < j; i++)
for (int j = 0; j < searchFieldLen ; j++)
salad[i][j] = EMPTY_CHAR;
}
// place Words
for (int wordNumber = 0; wordNumber < wordCount; wordNumber++)
{
srand(time(NULL));
int wordlength = strlen(words[wordNumber]);
int placed = 0;
for (int try = 0; (try < MAX_RAND_TRIES_PER_WORD) && !placed; try++)
{
int horizontal = rand() % 2;
int horizontal = rand() % 2; // 0 vertikal --> 1 horizontal
int x = rand() % searchFieldLen;
int y = rand() % searchFieldLen;
if (horizontal = 1)
if (horizontal)
{
if (x + wordlength > searchFieldLen) // word does not fit
{
@@ -46,18 +46,18 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
for (int i = 0; i < wordlength; i++) // position already occupied by other word
{
if (salad[y][x + 1] != EMPTY_CHAR)
if (salad[y][x + i] != EMPTY_CHAR)
{
fits = 0;
break;
}
}
if (fits = 1)
if (fits)
{
for (int i = 0; i < wordlength; i++)
{
salad[y][x + 1] = words[wordNumber][i];
salad[y][x + i] = words[wordNumber][i];
}
placed = 1;
placedWords++;
@@ -74,18 +74,17 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
for (int i = 0; i < wordlength; i++) // position already occupied by other word
{
if (salad[y + 1][x] != EMPTY_CHAR)
;
if (salad[y + i][x] != EMPTY_CHAR)
{
fits = 0;
break;
}
}
if (fits = 1)
if (fits)
{
for (int i = 0; i < wordlength; i++)
{
salad[y + 1][x] = words[wordNumber][i];
salad[y + i][x] = words[wordNumber][i];
}
placed = 1;
placedWords++;
@@ -101,7 +100,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
{
if (salad[i][j] == EMPTY_CHAR)
{
salad[i][j] = (rand() % ((90 - 65) + 1)) + 65; // 90 ist Z in ASCII und A ist 65
salad[i][j] = rand() % ('Z' - 'A' + 1) + 'A'; // 90 ist Z in ASCII und A ist 65
}
}
}
Binary file not shown.
Binary file not shown.
+5
View File
@@ -27,6 +27,11 @@ while (fgets(line, sizeof(line), file) && (count < maxWordCount))
char *token = strtok(line, " ;,");
while (token && (count < maxWordCount))
{
for (int i = 0; token[i] != '\0'; i++)
{
token[i] = toupper(token[i]);
}
strcpy(words[count], token);
count++;
token = strtok(NULL, " ;,");
Binary file not shown.
Binary file not shown.
+6
View File
@@ -6,6 +6,12 @@ BINARIES = ./windows
raylibfolder = ./raylib
unityfolder = ./unity
# --------------------------
# my version
# --------------------------
wordsalad_myversion: main.o graphicalGame.o
$(CC) main.o graphicalGame.o -o wordsalad_myversion $(BINARIES)/libwordsalad.a $(BINARIES)/libraylib.a $(LDFLAGS)
# --------------------------
# initiales Spiel bauen
# --------------------------
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.