diff --git a/Start_Windows/game.c b/Start_Windows/game.c index 9a6ed1b..d02b038 100644 --- a/Start_Windows/game.c +++ b/Start_Windows/game.c @@ -113,7 +113,7 @@ void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], } -int main(void) +/*int main(void) { // Spielfeldgröße unsigned int searchFieldLen = 15; @@ -143,7 +143,7 @@ int main(void) showWordSalad(salad, searchFieldLen); return 0; -} +}*/ diff --git a/Start_Windows/game.o b/Start_Windows/game.o new file mode 100644 index 0000000..36e03bd Binary files /dev/null and b/Start_Windows/game.o differ diff --git a/Start_Windows/graphicalGame.c b/Start_Windows/graphicalGame.c index fc648b6..7e04ee9 100644 --- a/Start_Windows/graphicalGame.c +++ b/Start_Windows/graphicalGame.c @@ -2,7 +2,7 @@ #include #include "graphicalGame.h" -#include "raylib.h" +#include "raylib/raylib.h" #define MAX_MESSAGE_LEN 256 #define MAX_SOLUTION_WORD_LEN 16 diff --git a/Start_Windows/graphicalGame.o b/Start_Windows/graphicalGame.o new file mode 100644 index 0000000..b249e6b Binary files /dev/null and b/Start_Windows/graphicalGame.o differ diff --git a/Start_Windows/input.c b/Start_Windows/input.c index ed77805..33f28b9 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -8,5 +8,41 @@ // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { + int wordCount = 0; + char line[MAX_WORD_LEN]; + while (wordCount < maxWordCount && fgets(line, MAX_LINE_LEN, file) != NULL){ + + line[strcspn(line, "\n")] ='\0'; + + /*strncpy(words[wordCount], tempBuffer, MAX_WORD_LEN -1); + words[wordCount][MAX_WORD_LEN - 1] = '\0';*/ + const char *teiler = ";,\n "; + char *token; + + token = strtok(line, teiler); + + while (token != NULL){ + strncpy(words[wordCount], token, MAX_WORD_LEN); + words[wordCount][MAX_WORD_LEN-1] = '\0'; + for (int i = 0; words[wordCount][i] != '0'; i++){ + char currentLetter = words[wordCount][i]; + if (currentLetter >= 'a' && currentLetter <= 'z'){ + words[wordCount][i] = currentLetter - ('a' - 'A'); + } + } + token = strtok(NULL, teiler); + wordCount++; + } + + /*for (int i = 0; words[wordCount][i] != 0 && i < MAX_WORD_LEN; i++) { + + char currentLetter = words[wordCount][i]; + if (currentLetter >= 'a' && currentLetter <= 'z'){ + words[wordCount][i] = currentLetter - ('a'-'A'); + } + }*/ + } + + return wordCount; } \ No newline at end of file diff --git a/Start_Windows/input.o b/Start_Windows/input.o new file mode 100644 index 0000000..df72e77 Binary files /dev/null and b/Start_Windows/input.o differ diff --git a/Start_Windows/main.c b/Start_Windows/main.c index 03da755..af79994 100644 --- a/Start_Windows/main.c +++ b/Start_Windows/main.c @@ -33,6 +33,8 @@ int main(int argc, char *argv[]) wordCount = readWords(file, words, MAX_NUMBER_OF_WORDS); fclose(file); + placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount); + // Create the word salad by placing words into grid placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount); @@ -40,7 +42,10 @@ int main(int argc, char *argv[]) // 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("Starting Game\n"); + startGame(wordSalad, SALAD_SIZE, words, wordCount, 800); + } } else { diff --git a/Start_Windows/main.o b/Start_Windows/main.o new file mode 100644 index 0000000..205a71d Binary files /dev/null and b/Start_Windows/main.o differ diff --git a/Start_Windows/makefile b/Start_Windows/makefile index 72cccb7..3b71937 100644 --- a/Start_Windows/makefile +++ b/Start_Windows/makefile @@ -43,3 +43,10 @@ test: input.o game.o unit_tests.c # -------------------------- clean: del /f *.o *.exe +OBJS_MYVERSION = main.o input.o game.o graphicalGame.o + +wordsalad_myversion: $(OBJS_MYVERSION) + $(CC) -o wordsalad_myversion $(OBJS_MYVERSION) $(BINARIES)/libwordsalad.a $(BINARIES)/libraylib.a $(LDFLAGS) + +%.o: %.c + $(CC) -c $< -o $@ $(CFLAGS) \ No newline at end of file