This commit is contained in:
sengpielto106561 committed 2026-10-29 15:24:46 +01:00
commit 547fc13e0f
2 files changed
+29 -8

No files matched your search

+17 -7
View File
@@ -1,6 +1,5 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "input.h" #include "input.h"
#include "game.h" #include "game.h"
#include "graphicalGame.h" #include "graphicalGame.h"
@@ -8,6 +7,8 @@
#define MAX_NUMBER_OF_WORDS 100 #define MAX_NUMBER_OF_WORDS 100
#define SALAD_SIZE 36 #define SALAD_SIZE 36
<<<<<<< HEAD
=======
int checkSalad(char words[][MAX_WORD_LEN], char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], int placedWords, int wordCount){ int checkSalad(char words[][MAX_WORD_LEN], char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], int placedWords, int wordCount){
//Iteriere über alle verfügbaren Wörter //Iteriere über alle verfügbaren Wörter
int foundWords = 0; int foundWords = 0;
@@ -44,6 +45,7 @@ int checkSalad(char words[][MAX_WORD_LEN], char wordSalad[MAX_SEARCH_FIELD_LEN][
return -1; return -1;
} }
>>>>>>> 61221a5b8ddad53683e9cad057577a9e8b9ea958
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int exitCode = EXIT_SUCCESS; int exitCode = EXIT_SUCCESS;
@@ -54,10 +56,11 @@ int main(int argc, char *argv[])
fprintf(stderr, "Usage: %s <path to file with search words>\n", argv[0]); fprintf(stderr, "Usage: %s <path to file with search words>\n", argv[0]);
exitCode = EXIT_FAILURE; exitCode = EXIT_FAILURE;
} }
else else
{ {
char words[MAX_NUMBER_OF_WORDS][MAX_WORD_LEN]; // Array to hold the words to be used in the game char words[MAX_NUMBER_OF_WORDS][MAX_WORD_LEN]; // Array to hold the words to be used in the game
unsigned int wordCount = 0; int wordCount = 0;
FILE *file = fopen(argv[1], "r"); FILE *file = fopen(argv[1], "r");
@@ -76,12 +79,19 @@ int main(int argc, char *argv[])
// TODO: // TODO:
// Check if all words were successfully placed // Check if all words were successfully placed
// Start the game if successful // Start the game if successful
// error message if some words couldn't be placed // error message if some words couldn't be placed (return input.c / game.c <=0)
int check = checkSalad(words, wordSalad, placedWords, wordCount); // Prüfen, ob input.c (readWords) einen Fehler oder 0 Wörter zurückgegeben hat
//Fehlerfall if (wordCount <= 0)
if(check != 0){ {
fprintf(stderr, "Not all words could be placed!\n"); fprintf(stderr, "Fehler: Es konnten keine Wörter eingelesen werden (input.c Rückgabewert <= 0).\n");
exitCode = EXIT_FAILURE;
}
// Prüfen, ob game.c (createWordSalad) einen Fehler zurückgegeben hat (<= 0) oder ob nicht alle eingelesenen Wörter platziert werden konnten
else if (placedWords <= 0 || placedWords < wordCount)
{
fprintf(stderr, "Fehler: Nicht alle Wörter konnten im Wortsalat platziert werden (game.c Rückgabewert <= 0).\n");
exitCode = EXIT_FAILURE; exitCode = EXIT_FAILURE;
} }
//keine Ahnung wiegroß pixelSize sein soll //keine Ahnung wiegroß pixelSize sein soll
+12 -1
View File
@@ -16,12 +16,14 @@ raylibfolder = ./raylib
unityfolder = ./unity unityfolder = ./unity
codefolder = . codefolder = .
# -------------------------- # --------------------------
# initiales Spiel bauen # initiales Spiel bauen
# -------------------------- # --------------------------
wordsalad_initial: wordsalad_initial:
$(CC) -o wordsalad_initial -L. $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS) $(CC) -o wordsalad_initial -L. $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
# -------------------------- # --------------------------
# Normales Spiel bauen # Normales Spiel bauen
# -------------------------- # --------------------------
@@ -48,6 +50,8 @@ TEST_BIN = runTests
test: input.o game.o $(codefolder)/unit_tests.c $(unityfolder)/unity.c test: input.o game.o $(codefolder)/unit_tests.c $(unityfolder)/unity.c
$(CC) -Wall -I$(unityfolder) -o $(TEST_BIN) input.o game.o $(codefolder)/unit_tests.c $(unityfolder)/unity.c $(CC) -Wall -I$(unityfolder) -o $(TEST_BIN) input.o game.o $(codefolder)/unit_tests.c $(unityfolder)/unity.c
# -------------------------- # --------------------------
# Clean # Clean
# -------------------------- # --------------------------
@@ -56,4 +60,11 @@ ifeq ($(OS),Windows_NT)
del /f *.o *.exe del /f *.o *.exe
else else
rm -f *.o wordsalad $(TEST_BIN) rm -f *.o wordsalad $(TEST_BIN)
endif endif
# --------------------------
# Eigene Version bauen (Deine main.c + libwordsalad.a)
# --------------------------
wordsalad_TMN: main.o graphicalGame.o $(BINARIES)/libwordsalad.a $(BINARIES)/libraylib.a
$(CC) $(CFLAGS) -o wordsalad_TMN main.o graphicalGame.o -L$(BINARIES) -lwordsalad $(BINARIES)/libraylib.a $(LDFLAGS)