diff --git a/.gitignore b/.gitignore index ef57c29..d076978 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ I2_Wortsalat/Start_Mac/input.o I2_Wortsalat/Start_Mac/game.o I2_Wortsalat/Start_Mac/runTests .o -.a \ No newline at end of file +.a diff --git a/I2_Wortsalat/.idea/.gitignore b/I2_Wortsalat/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/I2_Wortsalat/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/I2_Wortsalat/.idea/vcs.xml b/I2_Wortsalat/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/I2_Wortsalat/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/I2_Wortsalat/Start_Mac/.DS_Store b/I2_Wortsalat/Start_Mac/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/I2_Wortsalat/Start_Mac/.DS_Store differ diff --git a/I2_Wortsalat/Start_Mac/game.c b/I2_Wortsalat/Start_Mac/game.c index 4d257ce..1c8027c 100644 --- a/I2_Wortsalat/Start_Mac/game.c +++ b/I2_Wortsalat/Start_Mac/game.c @@ -115,5 +115,11 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi // Prints the word salad to console void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen) { - + for( int i = 0; i < searchFieldLen; i++ ) + { + for( int j = 0; j < searchFieldLen; j++ ) + { + printf("%c", salad[i][j]); + } + } } diff --git a/I2_Wortsalat/Start_Mac/input.c b/I2_Wortsalat/Start_Mac/input.c index f864eaf..43d8db7 100644 --- a/I2_Wortsalat/Start_Mac/input.c +++ b/I2_Wortsalat/Start_Mac/input.c @@ -28,7 +28,6 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) while (single_word != NULL && word_counter < maxWordCount) { - strncpy(words[word_counter], single_word, MAX_WORD_LEN - 1); words [word_counter][MAX_WORD_LEN -1] = '\0'; //Zur Sicherheit, damit \0 auf alle Fälle vorhanden ist word_counter++; diff --git a/I2_Wortsalat/Start_Mac/main.c b/I2_Wortsalat/Start_Mac/main.c index 03da755..ae0df05 100644 --- a/I2_Wortsalat/Start_Mac/main.c +++ b/I2_Wortsalat/Start_Mac/main.c @@ -38,13 +38,20 @@ int main(int argc, char *argv[]) // TODO: // Check if all words were successfully placed - // Start the game if successful - // error message if some words couldn't be placed - + if(placedWords == wordCount) + { + printf("Eingabe war erfolgreich!\nDas Spiel beginnt:"); + void startGame(wordSalad, searchFieldSize, words, numberOfWords, windowSize); + } + else + { + printf("Fehler! Es konnten nicht alle Woerter hinzugefuegt werden!\n Bitte Spiel neustarten!"); + } } else { // Print error message if file couldn't be opened + fprintf(stderr, "Could not open file %s for reading ...\n", argv[1]); exitCode = EXIT_FAILURE; } diff --git a/I2_Wortsalat/Start_Mac/makefile b/I2_Wortsalat/Start_Mac/makefile index 49654ae..e537fd4 100644 --- a/I2_Wortsalat/Start_Mac/makefile +++ b/I2_Wortsalat/Start_Mac/makefile @@ -3,44 +3,46 @@ CFLAGS = -g -Wall LDFLAGS = -framework OpenGL -framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Cocoa -framework CoreVideo ARCH := $(shell uname -m) BINARIES = ./macos-$(ARCH) - -raylib_folder = ./raylib +raylibfolder = ./raylib unityfolder = ./unity # -------------------------- # initiales Spiel bauen # -------------------------- + wordsalad_initial: - $(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS) +$(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS) # -------------------------- # Normales Spiel bauen # -------------------------- 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) +$(CC) $(CFLAGS) -o wordsalad main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(LDFLAGS) main.o: main.c - $(CC) -c $(CFLAGS) main.c +$(CC) -c $(CFLAGS) main.c input.o: input.c - $(CC) -c $(CFLAGS) input.c +$(CC) -c $(CFLAGS) input.c game.o: game.c - $(CC) -c $(CFLAGS) game.c +$(CC) -c $(CFLAGS) game.c graphicalGame.o: graphicalGame.c - $(CC) -I$(raylibfolder) -c $(CFLAGS) graphicalGame.c - +$(CC) -I$(raylibfolder) -c $(CFLAGS) graphicalGame.c # -------------------------- # Unit Tests # -------------------------- + TEST_BIN = runTests test: input.o game.o unit_tests.c $(BINARIES)/libunity.a - $(CC) -Wall -I$(unityfolder) -o $(TEST_BIN) input.o game.o unit_tests.c $(BINARIES)/libunity.a +$(CC) -Wall -I$(unityfolder) -o $(TEST_BIN) input.o game.o unit_tests.c $(BINARIES)/libunity.a + # -------------------------- # Clean # -------------------------- + clean: - rm -f *.o wordsalad +rm -f *.o wordsalad $(TEST_BIN) \ No newline at end of file diff --git a/I2_Wortsalat/Start_Windows/game.c b/I2_Wortsalat/Start_Windows/game.c index d8cc133..b9d31a9 100644 --- a/I2_Wortsalat/Start_Windows/game.c +++ b/I2_Wortsalat/Start_Windows/game.c @@ -14,10 +14,18 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount) { + + } // Prints the word salad to console void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen) { - + for( int i = 0; i < searchFieldLen; i++ ) + { + for( int j = 0; j < searchFieldLen; j++ ) + { + printf("%c", salad[i][j]); + } + } } diff --git a/I2_Wortsalat/Start_Windows/main.c b/I2_Wortsalat/Start_Windows/main.c index 03da755..ae0df05 100644 --- a/I2_Wortsalat/Start_Windows/main.c +++ b/I2_Wortsalat/Start_Windows/main.c @@ -38,13 +38,20 @@ int main(int argc, char *argv[]) // TODO: // Check if all words were successfully placed - // Start the game if successful - // error message if some words couldn't be placed - + if(placedWords == wordCount) + { + printf("Eingabe war erfolgreich!\nDas Spiel beginnt:"); + void startGame(wordSalad, searchFieldSize, words, numberOfWords, windowSize); + } + else + { + printf("Fehler! Es konnten nicht alle Woerter hinzugefuegt werden!\n Bitte Spiel neustarten!"); + } } else { // Print error message if file couldn't be opened + fprintf(stderr, "Could not open file %s for reading ...\n", argv[1]); exitCode = EXIT_FAILURE; }