Template
Compare commits
5
Commits
main
...
2d66437324
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d66437324 | ||
|
|
1c919cb6e3 | ||
|
|
6f3446fa8d | ||
|
|
db1e31f237 | ||
|
|
a9d6d69bc1 |
@@ -13,7 +13,7 @@
|
|||||||
// Creates the word salad by placing words randomly and filling empty spaces
|
// Creates the word salad by placing words randomly and filling empty spaces
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
Printf("Hello World+1");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints the word salad to console
|
// Prints the word salad to console
|
||||||
|
|||||||
@@ -8,5 +8,30 @@
|
|||||||
// Read words from file and store in 'words' array
|
// Read words from file and store in 'words' array
|
||||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||||
{
|
{
|
||||||
|
//kein fopen und close nötig, weil dies schon in der main passiert und mit *file übergeben wird//
|
||||||
|
|
||||||
|
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
perror("Error invalid pointer to file");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char line[1024];
|
||||||
|
unsigned int count = 0;
|
||||||
|
|
||||||
|
while (fgets(line, sizeof(line), file) && count < maxWordCount)
|
||||||
|
{
|
||||||
|
line[strcspn(line, "\n")] = '\0';
|
||||||
|
|
||||||
|
char *token = strtok(line, " ;,");
|
||||||
|
while (token && count < maxWordCount)
|
||||||
|
{
|
||||||
|
strcpy(words[count], token);
|
||||||
|
count++;
|
||||||
|
token = strtok(NULL, " ;,");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -40,7 +40,14 @@ int main(int argc, char *argv[])
|
|||||||
// 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
|
||||||
|
if (wordCount != placedWords)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: %u out of %u were placed\n", placedWords, wordCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
startGame(wordSalad, SALAD_SIZE, words, placedWords, 1024);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -g -Wall -I$(raylibfolder)
|
CFLAGS = -g -Wall
|
||||||
LDFLAGS = -lopengl32 -lgdi32 -lwinmm
|
LDFLAGS = -lopengl32 -lgdi32 -lwinmm
|
||||||
BINARIES = ./windows
|
BINARIES = ./windows
|
||||||
|
|
||||||
raylib_folder = ./raylib
|
raylibfolder = ./raylib
|
||||||
unityfolder = ./unity
|
unityfolder = ./unity
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
@@ -12,7 +12,6 @@ unityfolder = ./unity
|
|||||||
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
|
||||||
# --------------------------
|
# --------------------------
|
||||||
@@ -29,7 +28,7 @@ game.o: game.c
|
|||||||
$(CC) -c $(CFLAGS) game.c
|
$(CC) -c $(CFLAGS) game.c
|
||||||
|
|
||||||
graphicalGame.o: graphicalGame.c
|
graphicalGame.o: graphicalGame.c
|
||||||
$(CC) -I$(raylib_folder) -c $(CFLAGS) graphicalGame.c
|
$(CC) -I$(raylibfolder) -c $(CFLAGS) graphicalGame.c
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
# Unit Tests
|
# Unit Tests
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user