From 6eb6f6acc3ad43e6d6c86645df4856a4508c13ff Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 29 Oct 2026 14:04:39 +0100 Subject: [PATCH] =?UTF-8?q?game.c=20platzierte=20W=C3=B6rter=20z=C3=A4hlen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Startcode/game.c | 10 +++++++--- Startcode/makefile | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Startcode/game.c b/Startcode/game.c index 394c2e7..2d851e0 100644 --- a/Startcode/game.c +++ b/Startcode/game.c @@ -16,7 +16,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi { srand(time(NULL)); - int startpoint_x, startpoint_y, direction, possible, tries; + int startpoint_x, startpoint_y, direction, possible, tries, wordsplaced = 0; for(int i = 0; i < searchFieldLen; i++){ for(int j = 0; j < searchFieldLen; j++){ @@ -51,6 +51,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi salad[startpoint_x + j][startpoint_y] = words[i][j]; } break; + wordsplaced += 1; case 1: //X-Negativ startpoint_x = strlen(words[i]) - 1 + rand() % (searchFieldLen - strlen(words[i]) + 1); startpoint_y = rand() % searchFieldLen; @@ -70,6 +71,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi salad[startpoint_x - j][startpoint_y] = words[i][j]; } break; + wordsplaced += 1; case 2: //Y-Positiv startpoint_x = rand() % searchFieldLen; startpoint_y = rand() % (searchFieldLen - strlen(words[i]) + 1); @@ -87,7 +89,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi for(int j = 0; j < strlen(words[i]); j++){ salad[startpoint_x ][startpoint_y + j] = words[i][j]; - } + } + wordsplaced += 1; break; case 3: //Y-Negativ startpoint_x = rand() % searchFieldLen; @@ -107,6 +110,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi for(int j = 0; j < strlen(words[i]); j++){ salad[startpoint_x][startpoint_y - j] = words[i][j]; } + wordsplaced += 1; break; } } @@ -121,5 +125,5 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi } } } - return 0; + return wordsplaced; } diff --git a/Startcode/makefile b/Startcode/makefile index a36fd9f..914178d 100644 --- a/Startcode/makefile +++ b/Startcode/makefile @@ -26,7 +26,7 @@ wordsalad_initial: # Normales Spiel bauen # -------------------------- wordsalad_myversion: - $(CC) -o wordsalad_initial -L. $(BINARIES)/main.c $(BINARIES)/libraylib.a $(LDFLAGS) + $(CC) -o wordsalad_initial -L. $(codefolder)/main.c $(BINARIES)/libraylib.a $(LDFLAGS) wordsalad: main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(CC) $(CFLAGS) -o wordsalad main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(LDFLAGS)