Merge branch 'nico'

This commit is contained in:
Jonas Urban 2025-10-21 15:11:09 +02:00
commit eb4d95e236
10 changed files with 64 additions and 21 deletions

2
.gitignore vendored
View File

@ -6,4 +6,4 @@ I2_Wortsalat/Start_Mac/input.o
I2_Wortsalat/Start_Mac/game.o I2_Wortsalat/Start_Mac/game.o
I2_Wortsalat/Start_Mac/runTests I2_Wortsalat/Start_Mac/runTests
.o .o
.a .a

8
I2_Wortsalat/.idea/.gitignore generated vendored Normal file
View File

@ -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

6
I2_Wortsalat/.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

BIN
I2_Wortsalat/Start_Mac/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -115,5 +115,11 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
// Prints the word salad to console // Prints the word salad to console
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen) 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]);
}
}
} }

View File

@ -28,7 +28,6 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
while (single_word != NULL && word_counter < maxWordCount) while (single_word != NULL && word_counter < maxWordCount)
{ {
strncpy(words[word_counter], single_word, MAX_WORD_LEN - 1); 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 words [word_counter][MAX_WORD_LEN -1] = '\0'; //Zur Sicherheit, damit \0 auf alle Fälle vorhanden ist
word_counter++; word_counter++;

View File

@ -38,13 +38,20 @@ 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 if(placedWords == wordCount)
// error message if some words couldn't be placed {
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 else
{ {
// Print error message if file couldn't be opened // Print error message if file couldn't be opened
fprintf(stderr, "Could not open file %s for reading ...\n", argv[1]); fprintf(stderr, "Could not open file %s for reading ...\n", argv[1]);
exitCode = EXIT_FAILURE; exitCode = EXIT_FAILURE;
} }

View File

@ -3,44 +3,46 @@ CFLAGS = -g -Wall
LDFLAGS = -framework OpenGL -framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Cocoa -framework CoreVideo LDFLAGS = -framework OpenGL -framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Cocoa -framework CoreVideo
ARCH := $(shell uname -m) ARCH := $(shell uname -m)
BINARIES = ./macos-$(ARCH) BINARIES = ./macos-$(ARCH)
raylibfolder = ./raylib
raylib_folder = ./raylib
unityfolder = ./unity unityfolder = ./unity
# -------------------------- # --------------------------
# initiales Spiel bauen # initiales Spiel bauen
# -------------------------- # --------------------------
wordsalad_initial: 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 # Normales Spiel bauen
# -------------------------- # --------------------------
wordsalad: main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a 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 main.o: main.c
$(CC) -c $(CFLAGS) main.c $(CC) -c $(CFLAGS) main.c
input.o: input.c input.o: input.c
$(CC) -c $(CFLAGS) input.c $(CC) -c $(CFLAGS) input.c
game.o: game.c game.o: game.c
$(CC) -c $(CFLAGS) game.c $(CC) -c $(CFLAGS) game.c
graphicalGame.o: graphicalGame.c graphicalGame.o: graphicalGame.c
$(CC) -I$(raylibfolder) -c $(CFLAGS) graphicalGame.c $(CC) -I$(raylibfolder) -c $(CFLAGS) graphicalGame.c
# -------------------------- # --------------------------
# Unit Tests # Unit Tests
# -------------------------- # --------------------------
TEST_BIN = runTests TEST_BIN = runTests
test: input.o game.o unit_tests.c $(BINARIES)/libunity.a 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
# -------------------------- # --------------------------
clean: clean:
rm -f *.o wordsalad rm -f *.o wordsalad $(TEST_BIN)

View File

@ -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) 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 // Prints the word salad to console
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen) 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]);
}
}
} }

View File

@ -38,13 +38,20 @@ 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 if(placedWords == wordCount)
// error message if some words couldn't be placed {
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 else
{ {
// Print error message if file couldn't be opened // Print error message if file couldn't be opened
fprintf(stderr, "Could not open file %s for reading ...\n", argv[1]); fprintf(stderr, "Could not open file %s for reading ...\n", argv[1]);
exitCode = EXIT_FAILURE; exitCode = EXIT_FAILURE;
} }