Makefile
This commit is contained in:
commit
356bb5cb9e
4 files changed
+26
-12
No files matched your search
+17
-6
@@ -8,23 +8,34 @@
|
|||||||
// 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)
|
||||||
{
|
{
|
||||||
char puffer[MAX_WORD_LEN];
|
char puffer[MAX_LINE_NUMBER][MAX_LINE_LEN];
|
||||||
char *teiler = " ,;\n";
|
char *teiler = "\n ,;";
|
||||||
char *token;
|
char *token;
|
||||||
|
int i = 0;
|
||||||
unsigned int wordCount = 0;
|
unsigned int wordCount = 0;
|
||||||
|
|
||||||
fgets(puffer, MAX_LINE_LEN, file);
|
while(fgets(puffer[i], MAX_LINE_LEN, file) != NULL)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
token = strtok(puffer, teiler);
|
i = 0;
|
||||||
|
|
||||||
|
token = strtok(puffer[i], teiler);
|
||||||
|
|
||||||
while(token != NULL && wordCount < maxWordCount)
|
while(token != NULL && wordCount < maxWordCount)
|
||||||
{
|
{
|
||||||
strncpy(words[wordCount], token, MAX_WORD_LEN -1);
|
strncpy(words[wordCount], token, MAX_WORD_LEN -1);
|
||||||
words[wordCount][MAX_WORD_LEN - 1] = '\0';
|
//words[wordCount][MAX_WORD_LEN - 1] = '\0';
|
||||||
|
|
||||||
wordCount++;
|
wordCount++;
|
||||||
|
|
||||||
token =strtok(NULL, teiler);
|
token = strtok(NULL, teiler);
|
||||||
|
|
||||||
|
if(token == NULL && i < MAX_LINE_NUMBER)
|
||||||
|
{
|
||||||
|
token = strtok(puffer[i+1], teiler);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#define MAX_WORD_LEN 100
|
#define MAX_WORD_LEN 100
|
||||||
#define MAX_LINE_LEN 1024
|
#define MAX_LINE_LEN 1024
|
||||||
|
#define MAX_LINE_NUMBER 100 //Selbst hinzugefügt
|
||||||
|
|
||||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount);
|
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount);
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -36,10 +36,11 @@ int main(int argc, char *argv[])
|
|||||||
// Create the word salad by placing words into grid
|
// Create the word salad by placing words into grid
|
||||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// Check if all words were successfully placed
|
if(placedWords == wordCount)
|
||||||
// Start the game if successful
|
{
|
||||||
// error message if some words couldn't be placed
|
startGame(wordSalad, SALAD_SIZE, words, wordCount, 800);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
+3
-2
@@ -25,8 +25,9 @@ wordsalad_initial:
|
|||||||
# --------------------------
|
# --------------------------
|
||||||
# Normales Spiel bauen
|
# Normales Spiel bauen
|
||||||
# --------------------------
|
# --------------------------
|
||||||
my_wordsalad: main. o input.o $(BINARIES)/libwordsalad_complete.a
|
|
||||||
$(CC) $(CFLAGS) -o my_wordsalad main.o input.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
|
wordsalad_myversion: input.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a
|
||||||
|
$(CC) $(CFLAGS) -o wordsalad_myversion input.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
Reference in new issue
Block a user