Makefile
This commit is contained in:
commit
356bb5cb9e
4 files changed
+28
-14
No files matched your search
+19
-8
@@ -1,30 +1,41 @@
|
||||
#include "input.h"
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
// TODO:
|
||||
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
|
||||
|
||||
// Read words from file and store in 'words' array
|
||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
{
|
||||
char puffer[MAX_WORD_LEN];
|
||||
char *teiler = " ,;\n";
|
||||
char puffer[MAX_LINE_NUMBER][MAX_LINE_LEN];
|
||||
char *teiler = "\n ,;";
|
||||
char *token;
|
||||
unsigned int wordCount = 0;
|
||||
int i = 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)
|
||||
{
|
||||
strncpy(words[wordCount], token, MAX_WORD_LEN -1);
|
||||
words[wordCount][MAX_WORD_LEN - 1] = '\0';
|
||||
//words[wordCount][MAX_WORD_LEN - 1] = '\0';
|
||||
|
||||
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_LINE_LEN 1024
|
||||
#define MAX_LINE_NUMBER 100 //Selbst hinzugefügt
|
||||
|
||||
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
|
||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
||||
|
||||
// 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)
|
||||
{
|
||||
startGame(wordSalad, SALAD_SIZE, words, wordCount, 800);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
+3
-2
@@ -25,8 +25,9 @@ wordsalad_initial:
|
||||
# --------------------------
|
||||
# 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
|
||||
$(CC) $(CFLAGS) -o wordsalad main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(LDFLAGS)
|
||||
|
||||
Reference in new issue
Block a user